Can someone help me with a regular expression for matching hw:n,n?
where n is any number between 0-9.
an example string would be hw:0,1
Thanks.
That is very simple, just use the digit identifier \d
:
hw:\d,\d
https://regex101.com/r/oU1bI7/1
The above regex might also match other numerals, such as the arabic ones (see: https://stackoverflow.com/a/6479605/1105858)
If you want to limit to the actual 10 digits 0–9
, you can use it as a character class:
hw:[0-9],[0-9]
you can try this
hw:[0-9]+,[0-9]+
[0-9]+
: matches one or more digits
,
: matches a comma