raju
raju

Reputation: 4978

Regex question to have substring match given strings

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?

Upvotes: 0

Views: 57

Answers (2)

Daniil Fajnberg
Daniil Fajnberg

Reputation: 18458

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.*

Upvotes: 0

Barmar
Barmar

Reputation: 780984

Use alternatives:

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

Upvotes: 2

Related Questions