my first production regex for jesse

2007-08-25 @ 17:19#

i got to put my regex gains to work today for jesse's machina site. he uses snitz for his forum services. i helped him tie in the user-password functionality from sitz for the rest of his site, too (kinda cool). anyway, snitz uses forum codes for inline markup - kinda funky, but it's pretty common. but he wanted to display some of that snitz content in his own site pages. bummer of it is that all 'forum code' will appear 'as is' - it will not be translated into the proper HTML on his pages. so in i leap!

as a simple start, i wrote a regex that converts [url=""]go here[/url] into <a href="">go here</a>. pretty simple. the regex looks like this:


notice the &quot;? that's because we're applying this regex within XSLT - EXSLT, actually. the markup looks like this now:

        '&lt;a href=&quot;$1&quot;&gt;$2&lt;/a&gt;')" 

kinda gnarly, once you see it all put together. and i will admit, it took me a couple tries to get it working properly. but now that it works, it's pretty cool!