The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Death by regular expression by Hoth 2004-12-21 14:54:18

$hoth = preg_replace('<wasted time=(.*?)>/i', '[noresult]$1[/noresult]', $hoth);

I'm trying (using PHP) to replace HTML with friendlier codes (like what you'll find on most message boards) in a string. For some reason, my preg_replaces work fine for replacing <span> tags (and <b>, and most everything else) but fail to work with <div> tags.

This line works correctly, properly replacing <span style="font-style: italic;">x</span> with [i]x[/i]:
$msg = preg_replace('/<span style="font-style: italic;">(.*?)<\/span>/i', '[i]$1[/i]', $msg);

However, this line does nothing and leaves <div style="text-align: center;">x</div> untouched:
$msg = preg_replace('/<div style="text-align: center;">(.*?)<\/div>/i', '[center]$1[/center]', $msg);

I see no logical difference between the two, yet one works and the other doesn't. I've attempted some sacrificial offerings, but the gods do not seem to be moved yet. Must it be a human sacrifice before they'll make logic work for me again?

[ Reply ]
  My first guess would be that you need by ManiacJoe2004-12-21 17:50:08
    Was my guess as well by Hoth2004-12-21 19:41:52
      And preg_quote is no help by Hoth2004-12-21 19:50:31

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)