`\b\d+\b`matches a positive integer number. Do not forget the word boundaries!

`[-+]?\b\d+\b`allows for a sign.

`\b0[xX][0-9a-fA-F]+\b`matches a C-style hexadecimal number.

`((\b[0-9]+)?\.)?[0-9]+\b`matches an integer number as well as a floating point number with optional integer part.

`(\b[0-9]+\.([0-9]+\b)?|\.[0-9]+\b)`matches a floating point number with optional integer as well as optional fractional part, but does not match an integer number.

`((\b[0-9]+)?\.)?\b[0-9]+([eE][-+]?[0-9]+)?\b`matches a number in scientific notation. The mantissa can be an integer or floating point number with optional integer part. The exponent is optional.

`\b[0-9]+(\.[0-9]+)?(e[+-]?[0-9]+)?\b`also matches a number in scientific notation. The difference with the previous example is that if the mantissa is a floating point number, the integer part is mandatory.

If you read through the floating point number example, you will notice that the above regexes are different from what is used there. The above regexes are more stringent. They use word boundaries to exclude numbers that are part of other things like identifiers. You can prepend

`[-+]?`to all of the above regexes to include an optional sign in the regex. I did not do so above because in programming languages, the + and - are usually considered operators rather than signs.
## 0 Comments

Good day precious one, We love you more than anything.