Home > front end >  R: Regular expression of something has digits and number following
R: Regular expression of something has digits and number following

Time:11-10

What would the regular expression be for something that starts with "S" "0" "4 to 6" and followed by any number of digits or letters. For example, here are some values that I would like to capture:

  • S064X6S
  • S065X9D
  • S066X1S

This is what I have so far:

^S[0][6][4-6]\\d  

but it doesn't seem to capture the values I have above

CodePudding user response:

^S[0][6][4-6]\\w  

This did the trick!

CodePudding user response:

You don't need the square brackets for 0 and 6:

^S06[4-6]\\w 
  • Related