0

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.

Josh
  • 13,530
  • 29
  • 114
  • 159

2 Answers2

1

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]
Community
  • 1
  • 1
nils
  • 25,734
  • 5
  • 70
  • 79
1

you can try this

hw:[0-9]+,[0-9]+

[0-9]+: matches one or more digits

,: matches a comma

james jelo4kul
  • 839
  • 4
  • 17