I just ported a small gem from Ruby 1.9.3 to the spiffy new Ruby 2.0.0. The only change I had to make was in a regular expression.
Under 1.9.3, the following regex would match any string containing characters other than digits, number-related punctuation, and whitespace (including non-breaking space).
/[^[[:space:]]\d\-,\.]/
Under 2.0.0, I had to move the Posix space class away from the start of the negation class.
/[^\d\-,\.[[:space:]]]/
I haven't found this change mentioned in the patch notes I've reviewed. Is it documented anywhere?
The regular expression engine has been changed to Onigmo (based on Oniguruma) and this might be causing issues.
As far as I can tell, you're declaring the regular expression incorrectly. The second set of brackets is not required:
/[^[:space:]\d\-,\.]/
The [:space:]
declaration is only invalid inside of a set so you will see it appear as [[:space:]]
if used in isolation. In your case you have several other additions to the set.
I'm not sure why \s
would not have sufficed in this case.
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