June 16th, 2012, 11:03 AM
Cut off string at not allowed tags in regex
I got this fine working regex to use with php's preg_match_all to match a string containing 0 to x lines before and 0 to y lines after a specific word in a sentence/string:
Now, I want the string to be cut off when specific tags occur. So I was thinking about implementing this part in this string above:
in which $allowed_tags is a php variable that could look like this for example: '(frame|head|span|script)'
Despite trying to get this to work with lookahead, lookbehind and other conditions I can't get it working properly and I unfortunately have to admit this is way beyond my programming skills.
Hopefully someone can help me with this? I am sure someone among you geniuses can
Thanks a lot in advance!