PDA

View Full Version : Ignore everything between '<' and '>' and '&' and ';' using preg_replace?


Link14716
09-02-2003, 08:04 PM
Say I have this:
$newstring = preg_replace($patterns, $replacements, $string);
Now, $string may or may not have HTML tags in it, and if it does, the replacement will most likely b0rk them. So, how can I make it so that it just ignores anything between '<' and '>' and also '&' and ';'?

Also, how can I make it where it will ONLY affect things between '<' and '>' and also '&' and ';'? Thanks. :)

SmEdD
09-02-2003, 08:16 PM
Take a look at this hack https://vborg.vbsupport.ru/showthread.php?s=&threadid=56589

Link14716
09-02-2003, 08:20 PM
That doesn't really have anything to do with what I need.

Xenon
09-02-2003, 11:17 PM
have you tried striptags() function as it's buildin in php? ^^

Link14716
09-02-2003, 11:23 PM
I'm not trying to strip the tags, I want it to make it where preg_replace will not replace anything within a tag or only replace things within a tag (I need to know how to do both). That way, If I replace the letter "A" with the letter "Y", I won't have <y href="http://www.blyh.tld">, when it should still be <a href="http://www.blah.tld">. Stripping it out completely won't help much. ;)

Xenon
09-03-2003, 08:27 PM
ahh sorry i missunderstood what you wanted :)

hmm, sorry can't help further, i'm really not goot in regular expr.