Page 2 of 2
Posted: Tue Jun 10, 2003 8:29 am
by patrikG
Have you tried
addslashes($keyword) as well as adding to the regEx a conditional 's ?
So instead of
'/([^<.+>=])(red\.?)(.*<\/a>)?/i'
you would have
'/([^<.+>=])(".addslashes($keyword)."[''s]?\.?)(.*<\/a>)?/i'
?
Posted: Tue Jun 10, 2003 8:40 am
by Rayearth
Just tried, now the regEx reads:
$data = preg_replace('/([^<.+>=])('.addslashes($keys[$i]).'\.?)(.*<\/a>)?/i',' '.$searchstr.'\3',$data);
But still doesn't seem to work...
I'm not including the conditional 's because I don't want to change the array just yet...
Posted: Thu Jun 12, 2003 2:48 am
by patrikG
Sorry, Rayearth, I haven't had the time to deal with the regEx (end of project tomorrow). I don't think you're asking for the impossible, but it just is somewhat labour-intensive.
Just a thought which might make things a tad easier: have you considered exploding the string and then running preg_replace? Purpose of that is to have relevant chunks of the string where preg_replace is easier - and the poor regEx wouldn't need to do all the work.
But, on the other hand: have you managed to come up with a regEx that did the trick?
Posted: Thu Jun 12, 2003 3:49 am
by Rayearth
Hi patrikG,
Actually, I gave up using regEx and went back to writing a function to do the job using the "count open brackets and close brackets" with the string functions provided by PHP

It's working fine now, you can see the results at:
http://www.neorayearth.net/dimension4/m ... manga1.php
and
http://www.neorayearth.net/dimension4/m ... manga2.php
It's working pretty well, but I haven't tried giving it a LOT of text to go through so performance might be an issue... Still, I'm pretty pleased with not seeing any signs of lagging while going through 300 or so keywords to search and replace ^^
Thanks for everything anyway ^^