[OSM-dev] Semicolon
Dave Stubbs
osm.list at randomjunk.co.uk
Tue Nov 13 14:33:48 GMT 2007
On 13/11/2007, Richard Fairhurst <richard at systemed.net> wrote:
> Tom Hughes wrote:
>
> > Interesting... What's with all that weird 92.char stuff anyway... Any
> > comments Richard?
>
> Just that gsub('\','\\') didn't appear to work whereas
> gsub(92.chr,92.chr+92.chr) did!
You have to escape the \ in the string...
so in normal ruby strings:
'\' = ?? what are you typing?!
'\\' = \
'\\\\' = \\
in gsub replace (the second param):
'\\' = \ = \
'\\\\' = \\ = \
'\\\\\\' = \\\ = \\
'\\\\\\\\' = \\\\ = \\
or if you put them in a block instead, they behave as normal strings.
So what you wanted was:
gsub('\\', '\\\\\\\\')
or:
gsub('\\') { '\\\\' }
or:
gsub(92.chr, 92chr * 4)
or:
gsub(92.chr) { 92.chr * 2 }
backslashes can be a pain :-(
More information about the dev
mailing list