I want to ‘correct’ filenames for unix shell so I want to preceed
any let’s say & with backslash. Here is code translated from my
original script in Perl – end of the function
return filename.gsub(/([;!&%$’ ])/,’\\1’)
However it doesn’t do anything good. If I put space in the middle
\ \1
the replacament is correctly recognized. But I don’t want to use
space in the middle. What’s wrong here?
On Sat, 18 Nov 2006 10:02:59 -0800, Paul L. [email protected]
wrote:
data.gsub!(%r{([;!&%$’ ])},‘\\\1’)
Thank you. But what is the interpretation of 5! backshlashes. First
two to achieve one textual backslash – the last one, to get the
on-fly variable. And the rest two?
Please search the mailing list archive - this question comes up at
least once a month.
Thank you, but as you can see – google – not in that context – so
often. I found ‘answer’ at RubyCentral, but I am still not convinced
it works properly. Why
\ \1
is ok, but
\\1
not? If there is some kind of two-pass parsing – as RubyCentral
explains
\ \1
should be converted to
\1
or even
1
but it is not.
It looks like some too greedy substitution/parsing algorithm – I mean
at first the two first backshlashes are grouped together, then the
second and the third.
Thank you. But what is the interpretation of 5! backshlashes. First
two to achieve one textual backslash – the last one, to get the
on-fly variable. And the rest two?
Please search the mailing list archive - this question comes up at
least once a month.