![]() |
ignore hyperlinked text
I have been working on some wp-plugin to practice php.
I have made a dictionary... which reads posts from wordpress post and the plugin converts difficult words stored in the a text file. Now I don't want the plugin to read hyperlinked text. how do I achieve that? here is my code. PHP Code:
|
Can anyone please reply?
|
You could use your function and then use a regular expression to remove all the <acronym> tags that appear inside <a> tags.
Here is a regular expression I have come up with. I have only tested it using a javascript regexp tester at http://www.regular-expressions.info/...ptexample.html It should be the same for PHP though: PHP Code:
|
Your regexp is far too greedy, if there's multiple occurences, you might find that it strips them all out and everything in between. Something like the following (untested) may work;
php Code:
|
Your right. I've tried to work mine a little since when I tried yours on the javascript tester page it didn't work with the following information:
Regexp: (<a[^>]*>)?(<acronym[^>]*>(.*?)</acronym>)(</a>)? Subject string: hey <a href="test"><acronym>yo</acronym> yo <acronym>bob</acronym></a> what's up? <a href="test">nothing</a> Replacement text: $1$3$4 Code:
$the_content = preg_replace('~(<a[^>]*>)?(<acronym[^>]*>(.*?)</acronym>)(</a>)?~i', '$1$3$4', $the_content); |
Thank you very much for the replies. I have used the following code now.
Code:
while(!preg_match(<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>,$the_content)) |
| All times are GMT. The time now is 05:12 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0