Regex Help

So, I answer a lot of questions here - can I abuse the relationship with you readers and ask for your help? I finally have some folks using Canvas, my ColdFusion Wiki, and because of this, bugs are cropping up.

The main bug involves the fact that some Wiki commands, like +…+ for bold, intefere with other commands, like the URL generator. I use [[url]] to create URLs, but if you do [[http://www.cnn.com/foo_mon]] then the parser will find the _ in the URL. If another _ exists later on, then a match is found.

What I need is to find matches that are not inside HTML. Apparently this is possible using negative lookbehind, which ColdFusion doesn’t support.

Does anyone have any bright ideas? I’ve noticed other Wikis seem to get around this by using tokens that can’t appear in URLs.

The other problem is that you can’t use + and _ in normal text either. So this “5+5 = 2” would be a problem. I’m thinking for that I may just ask people to escape, i.e., use 5++5=2. That seem ok to folks?

Raymond Camden's Picture

About Raymond Camden

Raymond is a developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Comments