

(?()then|else) where name is the name of a capturing group and then and else are any valid regexes (? a ) ? (?(one) b | c ) matches ab, the first c, and the second c in babxcac T (?! s ) matches the first t in streets. Similar to positive lookahead, except that negative lookahead only succeeds if the regex inside the lookahead fails to match.

T (?= s ) matches the second t in streets. In a pattern like one (?= two ) three, both two and three have to match at the position where the match of one ends. It does not consume any characters or expand the match. Matches at a position where the pattern inside the lookahead can be matched. But it will not backtrack into the group to try other permutations of the group.Ī (?> bc | b ) c matches abcc but not abc If the remainder of the regex fails, the engine may backtrack over the group if a quantifier or alternation makes it optional. ( x ) (?| ( a ) | ( bc ) | ( def ) ) \2 matches xaa, xbcbc, or xdefdef with the first group capturing x and the second group capturing a, bc, or defĪtomic groups prevent the regex engine from backtracking back into the group after a match has been found for the group. If the regex inside the branch reset group has multiple alternatives with capturing groups, then the capturing group numbers are the same in all the alternatives. Regular Expression Reference: Special GroupsĮverything between (?# and ) is ignored by the regex engine.
