• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

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

tenants

Well-known member
#1
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
 

tenants

Well-known member
#3
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