From:                   "Beau E. Cox" <[EMAIL PROTECTED]>
> I have a file name in $_; I want to changes \s to
> /s and escape spaces.
> 
> This works fine:
> 
>  s/\\/\//g;
>  s/ /\\ /g;
> 
> How can I write that as one regex?

s{([ \\])}{$1 eq '' ? '\ ' : '/'}ge;
 
> Again - how can I strip "s from the beginning AND
> end of a scalar w/one reges, not these two?
> 
>  s/^"//;
>  s/"$//;

s/^"(.*)"$/$1/;
        # this assumes that there is a quote both on the beginning 
        # and the end. So it's not strictly equivalent to those two!

s/^"?(.*?)"?$/$1/;
        # this does not assume that.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to