nk510
nk510

Reputation: 19

quick and dirty preg_replace / regex (PHP)

I recently moved over my php based forum to a different version, one of the bbcodes needs to be slightly changed... so was hoping for some regex help to replace the existing bbcode.

I'm pretty bad with regex and was wondering if someone could help me come up with regex for preg_replace that I could use to replace the bbcode.

basically I need to wrap quotes around the existing display name.

from [quote=Display Name] to [quote="Display Name"]

Thanks in advanced!

Upvotes: 1

Views: 57

Answers (1)

Sampson
Sampson

Reputation: 268424

The following appears to accomplish what you're asking:

echo preg_replace('/\[quote=(.*?)\]/', '[quote="$1"]', $code);

Demo: sandbox.onlinephpfunctions.com

Upvotes: 2

Related Questions