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 [video] tags ins开发者_运维知识库tead?
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.
%<video[^>]*>(.*?)</video>%
Of course, watch out for the perils of trying to mess with HTML via regex. There will be issues. As always.
If you want [video] instead, just replace all <> with [] - but remember to escape them, since [ and ] are significant in regular expressions!
%\[video[^\]]*\](.*?)\[/video\]%
加载中,请稍侯......
精彩评论