------------------------------------------------
On Fri, 13 Dec 2002 08:30:24 -0500, "Paul Kraus" <[EMAIL PROTECTED]> wrote:

> Correct me if I am wrong but the only time you need to escape a
> backslash is if your regexpr is started and terminated with it. Since
> you are using {} I don't think you need to do that.
> 

You're wrong ;-).  Remember that the backslash is special for escaping any character 
in the string regardless of the delimiter used. I suppose there is probably a special 
variable to even change this, but is probably followed by one of the "Don't do that" 
in the docs.  Normally you would use / as your delimiter so you would have to 
backslash the /'s, but if you want to actually use \b in a string rather than the 
'word boundary' special char then you would have to \ the \, otherwise perl assumes 
that the \ is escaping the following character.  Not sure this is making much sense... 
I swear it sounds right in my head ;-)...

http://danconia.org


> > -----Original Message-----
> > From: John W. Krahn [mailto:[EMAIL PROTECTED]] 
> > Sent: Friday, December 13, 2002 8:25 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: Regex question
> > 
> > 
> > Colin Johnstone wrote:
> > > 
> > > Gidday all,
> > 
> > Hello,
> > 
> > > I have a paragraph of text, I want to convert any double 
> > quotes around 
> > > quoted text to \" is this the correct reg ex
> > > 
> > > $paragraph =~ s{\"}{\\"}g;
> > 
> > Yes that will work although you don't need to backslash the 
> > quote in the regular expression.
> > 
> > $ perl -le'$_ = q[one "two" three]; s{"}{\\"}g; print'
> > one \"two\" three
> > 
> > 
> > 
> > John
> > -- 
> > use Perl;
> > program
> > fulfillment
> > 
> > -- 
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

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

Reply via email to