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,
你的方法基本上是正确的,但你需要采取^和$出替代品,所以它们适用于正则表达式作为一个整体:
/^(?:[0-9A-F]{8}|[0-9A-F]{12}|[0-9A-F]{32})$/i
Run Code Online (Sandbox Code Playgroud)