Are these two equivalent? [0-9a-fA-F]
and [0-9a-f-A-F]
I've been trying these two regexes with egrep in some texts and they seem to be equivalent. Is there a case they won't be return same results?
Also, in the second expression, what is the meaning of the second -
and why would I need it? I am bit confused with these simple examples.
The second expression also matches a dash as well as hexadecimals
Edit in egrep
, which is what you're using the second one is in fact invalid:
# echo "12345678" | egrep '^[0-9a-f-A-F]+$'
egrep: Invalid range end
The correct expression for the second is by ending with a dash:
[0-9a-fA-F-]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With