0

We have been tasked with coming up with a regex that matches both integer and hexadecimal numbers (a number starting with '0x' followed by any combination of letters (a-f) and numbers).

Should match:

  • 0xa9bf
  • 42

Should not match:

  • a9bf
  • 0xg

What we have tried so far:

([0-9]+)|(0x[0-9a-fA-F]+)

This does not work however. Any suggestions to how we can improve?

Boris Grunwald
  • 2,602
  • 3
  • 20
  • 36

0 Answers0