This post originated from an RSS feed registered with Java Buzz
by Joe Shelby.
Original Post: Java Regex Gotchas...
Feed Title: Joe's Java Jottings
Feed URL: http://www.blog-city.com/bc/
Feed Description: Notes, observations, and occasional other stuff on Java, with concentrations on Swing, XML, and the Semantic (Object) Web.
When doing a substitution, jakarta regexp and oro will both consider the $g syntax, but ignore it if the $ in your replacement string isn't a digit, and simply return the $ untouched.
Java Regex, on the other hand, throws an exception if the character after the $ isn't a digit. The only way to handle it for now is to escape the $ with \ in the replacement before doing the substitution. Tiger will have a fix that can just turn the thing off entirely, but fat lot of good that does me now...
Should have just used jakarta-regexp to start with...
Actually, I played with extracting the "commons" (but not officially "commons") regex wrapper layer that Ant has, and I probably should have continued using that instead; it would allow me to quickly switch to a jakarta regex library without any code-changes. I might release that extracted codebase someday...