From 6ae66d73006153b773731e80bdf6dfabc54b1aff Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 5 Feb 2008 17:31:37 +0000 Subject: [PATCH] Backport doc fixes from 2.6. These are all things that were already supported but weren't in the docs, like conditional backreferences. --- Lib/re.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Lib/re.py b/Lib/re.py index 90956f34e23..f068ecd1899 100644 --- a/Lib/re.py +++ b/Lib/re.py @@ -29,7 +29,8 @@ concatenate ordinary characters, so last matches the string 'last'. The special characters are: "." Matches any character except a newline. "^" Matches the start of the string. - "$" Matches the end of the string. + "$" Matches the end of the string or just before the newline at + the end of the string. "*" Matches 0 or more (greedy) repetitions of the preceding RE. Greedy means that it will match as many repetitions as possible. "+" Matches 1 or more (greedy) repetitions of the preceding RE. @@ -37,7 +38,7 @@ The special characters are: *?,+?,?? Non-greedy versions of the previous three special characters. {m,n} Matches from m to n repetitions of the preceding RE. {m,n}? Non-greedy version of the above. - "\\" Either escapes special characters or signals a special sequence. + "\\" Either escapes special characters or signals a special sequence. [] Indicates a set of characters. A "^" as the first character indicates a complementing set. "|" A|B, creates an RE that will match either A or B. @@ -50,6 +51,10 @@ The special characters are: (?#...) A comment; ignored. (?=...) Matches if ... matches next, but doesn't consume the string. (?!...) Matches if ... doesn't match next. + (?<=...) Matches if preceded by ... (must be fixed length). + (?