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'
?
Regular Expression question
Moderator: General Moderators
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?
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?
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 ^^
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
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 ^^