In ruby 1.9.3 the regex engine doesn't treat nbsp's (\u00A0) as a space (\s). This is often a bummer for me.
So my question is, will this change in 2.0? If not, is there any way to monkey patch a solution?
Use Unicode properties (you need to declare a matching source code encoding for this to work):
# encoding=utf-8
if subject ~= /\p{Z}/
# subject contains whitespace or other separators
or use POSIX character classes:
if subject ~= /[[:space:]]/
According to the docs, \s
will only match [ \t\r\n\f]
now and in the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With