Skip to content

Instantly share code, notes, and snippets.

@tonysun83
Created March 24, 2015 19:52
Show Gist options
  • Save tonysun83/cad2d2456c518d878d08 to your computer and use it in GitHub Desktop.
Save tonysun83/cad2d2456c518d878d08 to your computer and use it in GitHub Desktop.
Regex for Floating Point, Hex Floating Point, Nan, and Infinity
Digits = "(\\p{N}+)",
HexDigits = "([0-9a-fA-F]+)",
Exp = "[eE][+-]?" ++ Digits,
FpRegexStr = "[\\x00-\\x20]*" ++ "[+-]?(" ++ "NaN|"
++ "Infinity|" ++ "((("
++ Digits
++ "(\\.)?("
++ Digits
++ "?)("
++ Exp
++ ")?)|"
++ "(\\.("
++ Digits
++ ")("
++ Exp
++ ")?)|"
++ "(("
++ "(0[xX]"
++ HexDigits
++ "(\\.)?)|"
++ "(0[xX]"
++ HexDigits
++ "?(\\.)"
++ HexDigits
++ ")"
++ ")[pP][+-]?" ++ Digits ++ "))" ++ "[fFdD]?))" ++ "[\\x00-\\x20]*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment