Regular Expressions 101

Community Patterns

any C-style integer

1

Regular Expression
PCRE (PHP <7.3)

/
(?<sign>[-+]?)(?<value>(?<hex>0x[0-9a-f]+)|(?<oct>0[0-7]+)|(?<dec>[0-9]+))(ul|l|u)?
/
gmi

Description

Grabs any C-style integer, including sign, prefix(0x for hex, 0 for octal), and suffix(U, L, UL)

Submitted by Daun Jeong - 8 years ago