Skip to content

Instantly share code, notes, and snippets.

@jeremy-rifkin
Created August 27, 2021 03:33
Show Gist options
  • Save jeremy-rifkin/0016b206cb726471bd44ac86ee44ab56 to your computer and use it in GitHub Desktop.
Save jeremy-rifkin/0016b206cb726471bd44ac86ee44ab56 to your computer and use it in GitHub Desktop.
regular expressions for c++ numeric literals
integer: (?:(?:0[Xx][0-9a-fA-F](?:'?[0-9a-fA-F])*)|(?:0[Bb][01](?:'?[01])*)|(?:0(?:'?[0-7])*)|(?:[1-9](?:'?\d)*))(?:[Uu](?:LL?|ll?|Z|z)?|(?:LL?|ll?|Z|z)[Uu]?)?
floating-point: (?:((?:\d(?:'?\d)*)?\.\d(?:'?\d)*|\d(?:'?\d)*\.)(?:[Ee][\+-]?\d(?:'?\d)*)?[FfLl]?|\d(?:'?\d)*[Ee][\+-]?\d(?:'?\d)*[FfLl]?|0[Xx](?:(?:[0-9a-fA-F](?:'?[0-9a-fA-F])*)?\.[0-9a-fA-F](?:'?[0-9a-fA-F])*|[0-9a-fA-F](?:'?[0-9a-fA-F])*\.)[Pp][\+-]?\d(?:'?\d)*[FfLl]?|0[Xx][0-9a-fA-F](?:'?[0-9a-fA-F])*[Pp][\+-]?\d(?:'?\d)*[FfLl]?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment