Below, there are some useful regular expressions for matching C-like primitive data values.

Before presenting the regular expressions I’ll introduce you first some named patterns:

/* universal character name */
UCN (\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{8})

/* exponent part of a floating point number */
EXP ([Ee][-+]?[0-9]+)

/* length part of an integer number */
ILEN ([Uu](L|l|LL|ll)?|(L|l|LL|ll)[Uu]?)

Having the above named patterns as basic building blocks we can describe more complex information.

For integer numbers:

/* integer in octal form */

/* integer in decimal form */

/* integer in hexadecimal form */

For floating point numbers:

/* floating point number in decimal form */

/* floating point number in hexadecimal form */

For character and string literals:

/* character literal */

/* string literal */

The following regular expression is for matching identifiers and does not describe a primitive data value. However, because it is a very important regular expression in most compilers and is related with primitive data types and values we present it:

/* identifier */