Wednesday, August 25, 2010

Eclipse regex for cfset annoyance

It's a pet peeve of mine: I like xhtml tags versus the older, semi-lazy html tags.

The HTML tag would be: cfset x = 1>
---(there should be a beginning Less than sign there, but this blogging software won't do it right)

The XHTML tag should be: cfset x = 1 />

I know it's nitpicky, but it's something I like. Until now, I'd been doing these replacements by hand, maybe a bit of find/replace when I knew the > was not part of a cfif or some other tag that would blow up if it was modified to end with a />

So, I looked around, found a regex to identify tags in html, and modified it to do my dirty work.
I put this in the find (need open LT):
  • cf(set|input|param|include|location|httpparam|queryparam|procparam|procresult|dump)(\b[^>]*[^V])([^\/])>
And this in replace:
  • cf\1\2\3 />
(Make sure to check the "Regular Expressions" checkbox in the search/replace!)


And it is like magical soothing balm to my neurosis!