Regex to match 8 or 12 or 32 hex number

Jak*_*ake 1 regex

I am trying to write a regex for a case-insensitive hex number that should match either 8 or 12 or 32 in length.

The regex I have so far is:

/^[0-9A-F]{8}|[0-9A-F]{12}|[0-9A-F]{32}$/i

The pattern I am trying to test against is:
96AFC4ADA8C44A36B0CB1EC28531C3BC

or

870b72a9a020

or

569ac61e
Run Code Online (Sandbox Code Playgroud)

But this doesn't seem to be matching the criteria.

Can you help?

Thanks,

Bar*_*mar 5

你的方法基本上是正确的,但你需要采取^$出替代品,所以它们适用于正则表达式作为一个整体:

/^(?:[0-9A-F]{8}|[0-9A-F]{12}|[0-9A-F]{32})$/i
Run Code Online (Sandbox Code Playgroud)