Reputation: 25
I'm looking for an efficient way to get a regex to greedily match any strings that are a sequential substrings of my pattern. For example, given the pattern "qwerty", I'd like it to match:
I don't want it to match non-sequential texts, or patterns that don't start at the beginning, such as:
Upvotes: 1
Views: 53
Reputation: 19206
Easy! You can use ?
for an optional occurrence.
^q(w(e(r(ty?)?)?)?)?
Upvotes: 2