![]() |
Majorly Advanced Regex
Looking for some clever clogs to figure out something for me:
Currently the strip_tags php function is rather rubbish, and simple folk must of wrote it! Well it doesn't check for the angle bracket within tag attributes. So for example you have the html code: Code:
<a onclick="javascript.writeln(\">these angl>>>>>>e brackets are smelly');">Boo Boo</a>What i am requesting is some regex that will handle it as it should returning 'Boo Boo', i've been fiddling with lookaheads, behinds and arounds and just can't get it to match the whole tag! |
I've arrived at a pattern (it's not majorly advanced, even if it has that appearance) from a starting point offered elsewhere where the same question was asked.
It basically looks for tags (items surrounded by <>), with the bulk of the pattern catering for optional content within the tag (attributes or other random junk).In tuning the pattern, I also wrote up a quick series of tests (generally something I do with all code snippets) which you can try out yourself. php Code:
It's only a very quick solution so there could well be huge flaws!! I'll look over it for potential problems when it's not so late and my eyes aren't struggling to focus on the screen. 8-) |
Quote:
Code:
<a onclick="javascript.writeln(\">\" you're going on where normal html browsers stop. |
| All times are GMT. The time now is 10:09 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0