Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Matching for the '¦' ?

Status
Not open for further replies.

Ayeka

Technical User
Jun 24, 2003
3
US
Gotta question:

I want to match things like ':|' ':_|' and exchange them for images. I have the exchange part down, but things with a '|' in the expression do not work. I've tried the following with no luck. Much thanks!

$message =~ s/\Q?:|\E/\<img border=\&quot;0\&quot; src=\&quot;$imagesdir\/huh.gif\&quot; alt=&quot;Huh&quot;>/g;

$message =~ s/(\W|\A)\?\:\|/$1\<img border=\&quot;0\&quot; src=\&quot;$imagesdir\/huh.gif\&quot; alt=&quot;Huh&quot;>/g;

$message =~ s/(\W)\?\:\|/$1\<img border=\&quot;0\&quot; src=\&quot;$imagesdir\/huh.gif\&quot; alt=&quot;Huh&quot;>/g;

...amoungst other possiblities. What am I missing?
 
If I understand you, then the | must be escaped with a \. So to match | in a regex you use \|.
 
I tried that, It's not working.
 
Did you try:

$message =~ s/:_\| || :\|/$1\<img border=\&quot;0\&quot; src=\&quot;$imagesdir\/huh.gif\&quot; alt=&quot;Huh&quot;>/g;
 
Hmmm, that's a little better...I think. Now I'm getting my icons with letters in between them:

Where O = image

O O<OyOaObOb ...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top