I have to check if a 4 character string is all valid hex, I found another question which demonstrates exactly what I want to do but it’s Java: Regex to check string contains only Hex characters
How can I accomplish this?
I read the ruby docs for Regular expressions, but I don’t understand how to return a true or false based on this match?
In ruby regex \h matches a hex digit and \H matches a non-hex digit.
So
!str[/\H/]is what you’re looking for.