Atomic groups prevent the regex engine from backtracking back into the group after a match has been found for the group. If the remainder of the regex fails, the engine may backtrack over the group if a quantifier or alternation makes it optional. But it will not backtrack into the group to try other permutations of the group.

Matches at a position where the pattern inside the lookahead can be matched. Matches only the position. It does not consume any characters or expand the match. In a pattern like one(?=two)three, both two and three have to match at the position where the match of one ends.

The text matched by the part of the regex to the left of the \K is omitted from the overall regex match. Other than that the regex is matched normally from left to right. Capturing groups to the left of the \K capture as usual.

(?(?=regex)then|else) where (?=regex) is any valid lookaround and then and else are any valid regexes

If the lookaround succeeds, the "then" part must match for the overall regex to match. If the lookaround fails, the "else" part must match for the overall regex to match. The lookaround is zero-length. The "then" and "else" parts consume their matches like normal regexes.

(?(regex)then|else) where regex, then, and else are any valid regexes and regex is not the name of a capturing group

If "regex" is not the name of a capturing group, then it is interpreted as a lookahead as if you had written (?(?=regex)then|else). If the lookahead succeeds, the "then" part must match for the overall regex to match. If the lookahead fails, the "else" part must match for the overall regex to match. The lookaround is zero-length. The "then" and "else" parts consume their matches like normal regexes.

(?(name)then|else) where name is the name of a capturing group and then and else are any valid regexes

If the capturing group with the given name took part in the match attempt thus far, the "then" part must match for the overall regex to match. If the capturing group did not take part in the match thus far, the "else" part must match for the overall regex to match.

(?<one>a)?(?(one)b|c) matches ab, the first c, and the second c in babxcac

(?(<name>)then|else) where name is the name of a capturing group and then and else are any valid regexes

If the capturing group with the given name took part in the match attempt thus far, the "then" part must match for the overall regex to match. If the capturing group did not take part in the match thus far, the "else" part must match for the overall regex to match.

(?<one>a)?(?(<one>)b|c) matches ab, the first c, and the second c in babxcac

(?('name')then|else) where name is the name of a capturing group and then and else are any valid regexes

If the capturing group with the given name took part in the match attempt thus far, the "then" part must match for the overall regex to match. If the capturing group did not take part in the match thus far, the "else" part must match for the overall regex to match.

(?'one'a)?(?('one')b|c) matches ab, the first c, and the second c in babxcac

(?(1)then|else) where 1 is the number of a capturing group and then and else are any valid regexes

If the referenced capturing group took part in the match attempt thus far, the "then" part must match for the overall regex to match. If the capturing group did not take part in the match thus far, the "else" part must match for the overall regex to match.

(?(-1)then|else) where -1 is a negative integer and then and else are any valid regexes

Conditional that tests the capturing group that can be found by counting as many opening parentheses of named or numbered capturing groups as specified by the number from right to left starting immediately before the conditional. If the referenced capturing group took part in the match attempt thus far, the "then" part must match for the overall regex to match. If the capturing group did not take part in the match thus far, the "else" part must match for the overall regex to match.

(?(+1)then|else) where +1 is a positive integer and then and else are any valid regexes

Conditional that tests the capturing group that can be found by counting as many opening parentheses of named or numbered capturing groups as specified by the number from left to right starting at the "then" part of conditional. If the referenced capturing group took part in the match attempt thus far, the "then" part must match for the overall regex to match. If the capturing group did not take part in the match thus far, the "else" part must match for the overall regex to match.

(?(+1)then|else) where 1 is the number of a capturing group and then and else are any valid regexes

The + is ignored and the number is taken as an absolute reference to a capturing group. If the referenced capturing group took part in the match attempt thus far, the "then" part must match for the overall regex to match. If the capturing group did not take part in the match thus far, the "else" part must match for the overall regex to match.