Numbersflags: g
Hexadecimal Number Literal
Match hexadecimal number literals like `0xFF`, `0x1A2B`, or `0XdeadBeef`.
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
\b0[xX][0-9a-fA-F]+\b (flags: g)Raw source: \b0[xX][0-9a-fA-F]+\b
How it works
\b is a word boundary so we don't match inside identifiers like `var0x10`. 0[xX] requires the literal prefix (case-insensitive on the x). [0-9a-fA-F]+ matches one or more hex digits in either case. Trailing \b avoids matching into adjacent letters.
Examples
Input
Mask = 0xFF; magic = 0xDEADBEEF;Matches
0xFF0xDEADBEEF
Input
Color #ff0000 vs literal 0xff0000Matches
0xff0000
Input
no hex hereNo match
—Common use cases
- •Source-code analysis for magic numbers
- •Memory-address parsing in stack traces
- •Color-format detection
- •Embedded / firmware tooling