I am trying to make a regex test that returns true for the following conditions:
- Can only have letters A-F (case insensitive)
- First character must be ‘#’
- Can have numbers 0-9
- Does not have punctuation
The order does not matter except that string should be ‘#’.
So far I have:
but for some reason, it returns strings that have letters after F (like G or J) as true.
You can use
^– start of string
#– a hash symbol
[0-9A-Fa-f]*– zero or more hex chars (note it can be written as
$– end of string.