3 ms·
Looks like there is already a gem backporting String#scrub: https://github.com/hsbt/string-scrub/ https://github.com/hsbt/string-scrub/ It was mentioned in the
by radq 13y ago
Looks like there is already a gem backporting String#scrub: https://github.com/hsbt/string-scrub/ https://github.com/hsbt/string-scrub/
It was mentioned in the changelog.
- jrochkind1 13y agoawesome, thanks. Looks like that backport may be only for ruby 2.0 (not 1.9), and is a compiled C extension. It won't take many lines of pure ruby code to do it for ruby 1.9 too, although presumably not performing quite as well as a C version. At any rate, this is definitely something I and people I know need to do all the time, although apparently most ruby devs never need to do it; but I'm glad it's finally made it into stdlib.
- jrochkind1 13y agoThat backport works on MRI 2.0. I've completed a pure-ruby polyfill that should work on 1.9 as well as 2.0, any ruby interpreter including jruby. (It does have some issues mentioned in the readme). https://github.com/jrochkind/scrub_rb https://github.com/jrochkind/scrub_rb