Sorry for the confusing name, I could not come up with the correct wording. I'm trying to figure out if there is a regular expression way to match different lines, depending on whether the previous capture group was captured or not.
/th?u(e|r)sday/
This corresponds to tuesday , thursday , but also thuesday and tursday . Is there a way to indicate in a regular expression that the part should only match if the previous part was matched ... so I present a potential syntax, for example ... (?#:pattern) where # is the number from the capture group, and if the captured group is captured, then the template is included, otherwise it is skipped. Same model (!#:pattern) if group # th is not captured. This invented syntax should demonstrate what I'm trying to do. With this invented syntax, I could solve my problem above, like this ...
/t(h)?u(!1:e)(?1:r)sday/
Is there such syntax in regex to achieve this type of link?
source share