Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression in Ruby to capture Unicode punctuation marks?

Tags:

regex

ruby

Is there a regular expression in Ruby that identifies Unicode punctuation (e.g., ",-)?

like image 992
Crashalot Avatar asked Feb 18 '23 02:02

Crashalot


2 Answers

You can use this one:

/[[:punct:]]/

For more info check the Regexp class. You can also test it on this Rubular permalink

like image 108
fmendez Avatar answered Feb 19 '23 16:02

fmendez


\p{P}

- not just in Ruby. See http://www.regular-expressions.info/unicode.html

like image 22
Alex Shesterov Avatar answered Feb 19 '23 14:02

Alex Shesterov