March 15, 2010 at March 15, 2010 · Filed under enart.nnxj.comedit
I'm writing some PHP code and I'd like to perform a smart text
replacement using EREGI_REPLACE.
In detail : I'd like to search for a particular string in a larger
string containing plain text mixed with some HTML tags. The difficulty
is : I don't want this search/replacement function to search inside
HTML tags, but ONLY in the rest of the text.
For example, here's some text I want to search into :
----
Hello http://www.something.com">everybody and everything,
how are you ?
----
I'd like to use EREGI_REPLACE so that it replaces the "thing" portion
from "everything" but NOT from the URL inside the tag.
How do you do that ?You could use the PREG_OFFSET_CAPTURE flag of the more powerful regexp
function preg_match function and check wether the match is inside a
HTML Tag.
I tried to do the same and ended up with a loop which steps through every character.Of course, the answer should apply to ANY HTML tag, not only the tag.#If you have any other info about this subject , Please add it free.# |
|