List Info

Thread: Ruby & gsub method




Ruby & gsub method
user name
2006-08-19 04:38:16
Hello all,

According to this link:

http://www.rubycentral.com/ref/ref_c_string.html#gsub

I would like to use ruby (a really cool language that you
should check
out if you haven't) to do something like this:

"Madison High School - WI".gsub(/([\s\-])/,
'\\1')

To transform the string to this:

"Madison\ High\ School\ \-\ WI"

Instead the method call returns this:

"Madison High School - WI"

I'm no master of regular expressions as this example
clearly
demonstrates and I'm sure I'm not escaping either the
regular
expression pattern or the replacement string.

Any assistance would be greatly appreciated.

Regards,

Bill


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )