
For example, "x(?!abc)" matches an "x" only if it is not followed by the expression "abc". pattern cannot contain a newline character.Ī subexpression that performs a negative lookahead search, which matches the search string at any point where a string not matching pattern begins.

This is a non-capturing match, that is, the match is not captured for possible later use with back references. For example, "x(?=abc)" matches an "x"only if it is followed by the expression "abc". For example, 'industr(?:y|ies) is a more economical expression than 'industry|industries'.Ī subexpression that performs a positive lookahead search, which matches the string at any point where a string matching pattern begins. This is useful for combining parts of a pattern with the "or" character (|). Ī subexpression that matches pattern but does not capture the match, that is, it is a non-capturing match that is not stored for possible later use with back references. If "name" is a number, it indicates a numbered back reference, equivalent to \1, \2, \3. A named back reference is a reference to a previous named capturing group using this form: (?expression). For example, "(h)(e)" will find "he", and putting "\1" in the Replace With box will replace "he" with "h" whereas "\2\1" will replace "he" with "eh". Use regular expressions to locate a text pattern, and the matching text can be replaced by a specified back reference. Back references can also be used when using the Replace feature under the Search menu. For example, "(a)\1" would capture "a" as the first back reference and match any text "aa". A back reference consists of the escape character "\" followed by a digit "1" to "9", "\1" refers to the first sub-expression, "\2" to the second etc. The reference is to what the sub-expression matched, not to the expression itself.

Indicates a back reference - a back reference is a reference to a previous sub-expression that has already been matched. M and n are nonnegative integers, where n pattern)Ĭaptures the string matched by "pattern" into the group "name".

* is equivalent to ' is equivalent to 'o*'. Matches the preceding character or sub-expression zero or more times. For example, "e$" matches any "e" that ends a string. Matches the position at the end of the input string. For example, "^e" matches any "e" that begins a string. Matches the position at the beginning of the input string. The sequence '\\' matches "\" and "\(" matches "(".

For example, 'n' matches the character "n". Marks the next character as a special character, a literal, or a back reference.
