Still doesn't exactly work... I think it's mainly because the example I gave you doesn't cover all the cases that's possible... Here's an example of what I'm trying to do:
http://www.neorayearth.net/dimension4/m ... manga1.php
The plain HTML code that's dumped at the beginning of the page is the text the regEx needs to go through to find and replace things with.
I'm using the regEx code:
Code: Select all
for ($i=0; $i<count($keys); $i++) {
$searchstr = "<a href=".$pre.$urlsї$i].$pos.">".$keysї$i]."</a>";
$data = preg_replace('/(ї^<.+>=])('.$keysї$i].'\.?)(.*<\/a>)?/i',' '.$searchstr.'\3',$data);
}
I have this a series of words I want to replace, hence I got a for loop going through the $keys array which keeps all the keywords. The $urls array keeps a list of URLs for each keyword (the index matches the $keys index) whereas $pre and $pos are javascript/paths and brackets/quotes that I use to open those URLs with.
The list of stuff that I need replacing is over a hundred entries, so I'll just include a few:
Code: Select all
"Hikaru's", "hikaru.html"
"Hikaru", "hikaru.html"
"Umi's", "umi.html"
"Umi", "umi.html"
"Fuu's", "fuu.html"
"Fuu", "fuu.html"
"Princess Emeraude's", "emeraude.html"
"Princess Emeraude", "emeraude.html"
"Emeraude's", "emeraude.html"
"Emeraude", "emeraude.html"
"Lantis'", "lantis.html"
"Lantis", "lantis.html"
As you can see, I have a pair for each keyword due to the "'s" of all these keywords (they're all names) and sometimes even 2 pairs (such as the case of "Emeraude" since she is referred to with and without the "Princess" in front) and this has has somewhat complicated the problem... I've considered moving the "'s" clone out of the database and have just add an extra condition to match "'s" in the regEx, but this would generate another problem with cases like "Lantis" where there is no "s" after the '.
Currently, $pre and $pos are as follows, but they'll change depending what type of link it is:
Code: Select all
$pre = ""javascript:CharacterWindow('http://www.neorayearth.net/dimension4/mkr/char/"
$pos = "')""
I hope I'm not trying to do something impossible ~_~