in reply to Re: BBCodes, removing [URL's
in thread BBCodes, removing [URL's

Man, been playing with this for ages, and still not got it doing what I want :@

Any suggestions?

TIA

Andy

Replies are listed 'Best First'.
Re^3: BBCodes, removing [URL's
by moritz (Cardinal) on Apr 23, 2009 at 22:09 UTC
    What have you tried? From the documentation it doesn't seem too hard to add custom tags - did you manage that? If not, where did you fail?
      Ok,managed to sort it.

      my $test_string = q| [lien "dfgdgdg"][img]sdfsdfsdf[/img][/url] [lien "dfgdgdg33"][img]sdfsdfsdf[/img][/lien] Si qqn connait un transporteur ou une agence qui fais des bon prix [lien "http://www.smileycentral.com/?partner=ZSzeb001"][img]http://smi +leys.smileycentral.com/cat/12/12_1_220.gif[/img][/lien] pour l'australie je suis preneur merci............... BONNE ANNÉE [signature]|; $test_string =~ s/lien/url/sig; # the parser doesn't seem to like +this $test_string =~ s/\[url "([\?\%\:\/a-zA-Z0-9_\-\.=]+)"\]/[url=$1]/ +sig; while ($test_string =~ m%\[url=([\?\%\:\/a-zA-Z0-9_\-\.=]+)\]\[img +\]([\?\%\:\/a-zA-Z0-9_\-\.=]+)\[/img\]%gix) { print "FOO: $1 , and $2 \n"; }
      Seems to work fine:
      FOO: dfgdgdg , and sdfsdfsdf FOO: dfgdgdg33 , and sdfsdfsdf FOO: http://www.smileycentral.com/?partner=ZSzeb001 , and http://smile +ys.smileycentral.com/cat/12/12_1_220.gif


      Seems to be working ok atm - will do some more tests though.

      Weird thing though, is if I change the regex to:
      while ($test_string =~ m%\[lien \"([\?\%\:\/a-zA-Z0-9_\-\.=]+)\"\] +\[img\]([\?\%\:\/a-zA-Z0-9_\-\.=]+)\[/img\]\[/lien\]%gix) { print "FOO: $1 , and $2 \n"; }

      ..and get rid of the stuff that converts [lien "link"] to [url=whatever] .. it doesn't seem to work (no matches)

      Cheers

      Andy
      UPDATE - never mind - sorted it:

      Thanks for the help guys.

      Cheers

      Andy