Is this string a number? - 6 décembre 2010
A blog post (Double Parsing Regexp) caught my attention. The base problem is to check if a string is a valid number, without necessarily needing the real value. Or, perhaps, to skip the conversion if we are sure it will fail, as Double.valueOf throws an exception in this case, and the try/catch mechanism is known to be slow.
The numbers given were intriguing, and I wondered if the given regular expression could be optimized. Somehow, it was a great opportunity to use Caliper a library to do correctly micro-benchmarks.
Continuer à lire "Is this string a number?"