Home > database >  Regex question to have substring match given strings
Regex question to have substring match given strings

Time:02-04

I want regex to combine

".*SimpleTaskv9MoreDetails.*"

or

".*SimpleTaskv10MoreDetails.*"

How can I create regex to match both of them? I know that below one matches v8 and v9

".*SimpleTaskv[89]MoreDetails.*"

But if I want both v9 and v10 to be accepted? How do I do it?

CodePudding user response:

Use alternatives:

.*SimpleTaskv(?:9|10)MoreDetails.*

CodePudding user response:

If you want to generally match your existing pattern but with any non-zero-length sequence of digits in the middle, you could do this:

.*SimpleTaskv\d MoreDetails.*
  • Related