Skip to content
Advertisement

Tag: capture-group

Are non-capturing groups redundant?

Are optional non-capturing groups redundant? Is the following regex: semantically equivalent to the following regex? Answer Your (?:wo)?men and (wo)?men are semantically equivalent, but technically are different, namely, the first is using a non-capturing and the other a capturing group. Thus, the question is why use non-capturing groups when we have capturing ones? Non-caprturing groups are of help sometimes. To

Advertisement