1

I was using str_replace for other bbcodes, but I'm stuck with the url portion.

I need to convert:

[url=http://maps.google.com/maps?ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&q=brits+pub&near=Pasadena,+CA&fb=1&cid=0,0,17926180203917841249&sa=X&oi=local_result&resnum=1&ct=image]Brits[/url]

to

<a href="ttp://maps.google.com/maps?ie=UTF-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&q=brits+pub&near=Pasadena,+CA&fb=1&cid=0,0,17926180203917841249&sa=X&oi=local_result&resnum=1&ct=image">Brits</a>
Citizen
  • 12,430
  • 26
  • 76
  • 117

2 Answers2

2

Why don't you take a look at other BBCode parsers?

Just replacing tags isn't sufficient anyways, since this can (and will) lead to incorrect markup.

Franz
  • 11,353
  • 8
  • 48
  • 70
0

There is actually a good SO question about this already: Best way to parse bbcode.

Also, using an already existing BBCode parser library is advisable to attempting to making your own.

Community
  • 1
  • 1
Dostee
  • 734
  • 5
  • 12
  • @Franz - could you clarify: are you talking about a specific case? or are you saying this doesn't parse correctly? – Dostee Dec 17 '09 at 00:26
  • You edited your answer. Still: incorrectly nested tags? `[b][i][/b][/i]` – Franz Dec 17 '09 at 00:40