Monday, December 23, 2013

Regular Expressions

To match a floating point value in a substring I currently use the following regular expression:

(\d+(?:\.\d+)?(?:[eE][-+]?[0-9]+)?)

This matches:

  • 123
  • 123.4
  • 123.4E3
  • 123.4e-4
  • etc...


Does anyone have a better expression that matches example strings?
Please post in the comments below, thanks.

No comments:

Post a Comment