|
|
Subject:
PHP : using EREGI_REPLACE so that it doesn't search/replace inside HTML tags
Category: Computers > Programming Asked by: dfdfdfdfdfdf-ga List Price: $6.00 |
Posted:
31 Jan 2005 10:29 PST
Expires: 02 Mar 2005 10:29 PST Question ID: 466434 |
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 <A HREF="http://www.something.com">everybody and everything</A>, 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 <A ...> tag. How do you do that ? | |
|
|
There is no answer at this time. |
|
Subject:
Re: PHP : using EREGI_REPLACE so that it doesn't search/replace inside HTML tags
From: tyronx-ga on 27 Feb 2005 15:33 PST |
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. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |