Hi everyone!
I'm having trouble with a regular expression.
I am trying to replace an "ugly URL" on the fly with a nice URL. To do this, I am parsing huge chunks of texts.
I got it basically to work, but my problem is with links to third party sites. I don't want to have those "ugly URLs" replaced, since it wouldn't make much sense, as I have no control over those. 🙂
Since all links on my site link to the same directory and there are no / for my internal links, it shouldn't be that hard, but I am just stuck.
Could someone help me out on this?
You can see my code that will replace all links below.
Ciao
Sascha
$in = array("'modules.php\?op=modload&name=News&file=article&sid=([0-9])'");
/some additional conditions are cut out here, I use the array for multiple conditions*/
$out = array("article\1.html");
$string = preg_replace($in, $out, $string);