[MacRuby-devel] Scanning Unicode strings for non-ascii characters
Rich Morin
rdm at cfcl.com
Tue Mar 3 21:44:30 PST 2009
At 21:30 -0500 3/3/09, Robert Schaaf wrote:
> a_string.tr('^ -~', ' ') Any comments on efficiency?
That's pretty much equivalent to this code:
a.gsub(/[^\x20-\x7e]/, ' ')
It may or may not be faster, more to your taste, etc.
Before using it, be sure that you don't want to preserve
characters such as tabs and/or newlines...
-r
--
http://www.cfcl.com/rdm Rich Morin
http://www.cfcl.com/rdm/resume rdm at cfcl.com
http://www.cfcl.com/rdm/weblog +1 650-873-7841
Technical editing and writing, programming, and web development
More information about the MacRuby-devel
mailing list