سؤال

We are moving from phpbb to a simpler system and some of the bbcode needs converting, particularly the "quote" code. The current phpbb based quote code looks like this:

[quote="username":nw4lek0o]The quoted text[/quote:nw4lek0o]

and it needs to be simplified to this:

[quote=username]The quoted text[/quote]

So, basically two things: strip the double quotes from around the username, and strip the ID string from the opening and closing tag.

I'm not good at Regex. Help?

هل كانت مفيدة؟

المحلول

Use this regex:

\[quote="(.+?)":.+?\](.+?)\[/quote:.+?]

And replace it with:

[quote=$1]$2[/quote]

Demo: http://regex101.com/r/jL3xU2

نصائح أخرى

find (?=\").|(?::\w+) replace with blank.

demo here : http://regex101.com/r/oN8fS2

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top