Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Pattern Match Question..

Reply
Thread Tools

Pattern Match Question..

 
 
Rodney
Guest
Posts: n/a
 
      09-13-2003
I want to replace all instances of the combination of \" with \"

Using the Regex code below, I end up replacing ALL " with &guot; and all
\" with \&guot;
How can I make it ONLY replace the combination of \" ?

$TextBlockToConvert =~ s/\"/\quot;/g;

NOTE:
The combination of \" may or may not have other characters butting up
against either or both sides of it.


Thanks,
--
....
`·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney


 
Reply With Quote
 
 
 
 
John W. Krahn
Guest
Posts: n/a
 
      09-13-2003
Rodney wrote:
>
> I want to replace all instances of the combination of \" with \"
>
> Using the Regex code below, I end up replacing ALL " with &guot; and all
> \" with \&guot;
> How can I make it ONLY replace the combination of \" ?
>
> $TextBlockToConvert =~ s/\"/\quot;/g;


The backslash character is special in double quoted strings so you have
to escape it if you want a literal backslash character.

$TextBlockToConvert =~ s/\\"/"/g;



John
--
use Perl;
program
fulfillment
 
Reply With Quote
 
 
 
 
Rodney
Guest
Posts: n/a
 
      09-14-2003
That did it perlfectly!

Thanks John.
--
....
`·.¸¸.·´¯`·.¸¸.·´¯`·-> rodney


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
re.sub(): replace longest match instead of leftmost match? John Gordon Python 13 12-20-2011 02:58 AM
pat-match.lisp or extend-match.lisp in Python? ekzept Python 0 08-10-2007 06:08 PM
Match doesn't match Volkan Civelek Ruby 4 07-19-2006 07:44 AM
$match = true() for empty $match?? Victor XML 2 05-17-2004 10:43 AM
Java regex can't match lengthy match? hiwa Java 0 01-29-2004 10:09 AM



Advertisments