I’m trying to match tags using preg_replace. The regex used is: <video[^>]*>(.*?)</video>
But I’m getting a server warning: Message: preg_replace() [function.preg-replace]: Unknown modifier ']'
Any clues on why?
Also, How could I modify the regex so it can match tags instead?
Thanks!
Don’t forget to delimit your regex, as required in the
preg_functions. Usually we would write/regex/, but any delimiters will do.Since your regex contains
/, I’ll go for%, to avoid escaping it.Of course, watch out for the perils of trying to mess with HTML via regex. There will be issues. As always.
If you want
instead, just replace all<>with[]– but remember to escape them, since[and]are significant in regular expressions!