开发者

preg replace to remove bbcode quote

开发者 https://www.devze.com 2023-01-06 19:05 出处:网络
Could someone give me an example of how to I can remove开发者_StackOverflow [QUOTE=author;3095231] Author being the authors name, and 3095231 being the post.

Could someone give me an example of how to I can remove

开发者_StackOverflow
[QUOTE=author;3095231]

Author being the authors name, and 3095231 being the post.

I want to use preg replace, or anything similar but not sure how and was wondering for an example, I believe it would be something like [QUOTE=(.+?)] and i don't know the rest.


Your regex looks almost right to me, you must escape the brackets though.

Assuming it's in PHP, the corresponding code would look like

$text = preg_replace('/\[QUOTE=(.+?)\]/', '', $text);


The regular expression you're looking for is

s/\[QUOTE=[^\]]+\]//
0

精彩评论

暂无评论...
验证码 换一张
取 消