Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I am trying to make a regex that will match this pattern,
Must be 40 characters long,
Must contain only letters and numbers,
Must contain no spaces,
Case insensitive,
So far I have come up with this but it does not work;
/^[0-9a-f]+$/i
Thanks
a-f
/^[0-9a-f]{40}$/i
should do the trick. The number in curly brackets defines the number of characters.
Add a comment
Try this regex:
/^[\da-z]{40}$/i
If you really only want the letters a-f then use:
/^[\da-f]{40}$/i
\w
_
Try this:/^[0-9a-z]{40,40}$/i
/^[0-9a-z]{40,40}$/i
{40,40}
{40}
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
a-fbit is odd. You don't want to match on G through Z? Are you trying to match hexadecimal digits? If so, note that the maximum value of a hexadecimal digit is e (decimal 15), not f (decimal 16 is 10 in hex).