1st plugin, need some regex advice to remove BBCode [URL='websirte']

tenants

Well-known member
Licensed customer
Hi, I'm just creating my first mod

I'm very new to regex, and wondered if there any regex people here?

All I'm trying to do is convert:

PHP:
 a string [URL='anychars']sometext

to

PHP:
 a string sometext

What I've come up with so far is :

PHP:
$str = preg_replace('/[\[URL=\':.\/\-\d\w?\'\]]/', "", $sigLinks[$i]);

But this also removes the last part of the string "sometext"

I acutally wanted to use something like:

PHP:
preg_replace('/[\[URL=\'[.*]\'\]]/

but this didnt work either
 
This should work...

Code:
preg_replace('/\[url\=.*\](.*)\[\/url\]/i',"$1", $sigLinks[$i]);

But I haven't tested it.
 
That really helped, thanks Cezz.

It was only the first part of the URL bb code that I needed to take out (since the [/URL] was already taken out with an explode)

So I used your suggestion:

Code:
preg_replace('/\[url\=.*\]/i', "$1",  $sigLinks[$i]);

Worked like a dream, cheers
 
Back
Top Bottom