Skip to main content
AllDevToolsHub
Back to all patterns

Hexadecimal Number (0x prefix)

Dates & Numbers

Matches a 0x-prefixed hex literal.

/^0x[0-9a-fA-F]+$/

How it works

Standard hex notation in C, C++, Java, JS, Python, Rust, Go. Useful for parsing memory addresses, color codes (with leading 0x instead of #), and binary protocols.

Test Cases

Should Match

  • 0xFF
  • 0xdeadbeef
  • 0x0

Should NOT Match

  • FF
  • 0x
  • 0xG

Quick Summary

Matches a 0x-prefixed hexadecimal literal.