1. 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']

Discussion in 'XenForo Development Discussions' started by tenants, Aug 29, 2011.

  1. tenants

    tenants Well-Known Member

    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:

     a string [URL='anychars']sometext 

     a string sometext 
    What I've come up with so far is :

    $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:

    but this didnt work either
  2. Cezz

    Cezz Well-Known Member

    This should work...

    preg_replace('/\[url\=.*\](.*)\[\/url\]/i',"$1", $sigLinks[$i]);
    But I haven't tested it.
    tenants likes this.
  3. tenants

    tenants Well-Known Member

    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:

    preg_replace('/\[url\=.*\]/i', "$1",  $sigLinks[$i]);
    Worked like a dream, cheers
  4. tenants

    tenants Well-Known Member

Share This Page