Created
January 27, 2012 11:25
-
-
Save rowanj/1688354 to your computer and use it in GitHub Desktop.
Regex to match any decimal number in source files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
([+-])?(0|[1-9][0-9]*)(?:\.([0-9]+))?(?:[Ee]([+-])?(0|[1-9][0-9]*)(?:\.([0-9]+))?)? |
6 capturing groups:
group 1: ([+-]) sign
group 2: (0|[1-9][0-9]) integer part
group 3: ([0-9]+) decimal part
group 4: ([+-]) exponent sign
group 5: (0|[1-9][0-9]) exponent integer part
group 6: ([0-9]+) exponent decimal part
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Aim is to be parseable in each present logical component; sign, integral part, decimal part, exponent sign, exponent integral part, exponent decimal part.