Unicode Support

Ruby has some UTF-8 support, but you have to enable it by including the line $KCODE = "UTF8" before using the constructs. When enabled, the metasequences \w, \d, \s, and \b support Unicode characters outside of the ASCII range. You can also enable multibyte regex processing by passing a language parameter to Regexp.new, and turn off multibyte processing with the /n modifier.

Get Regular Expression Pocket Reference, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.