Commit 22c003b
committed
Restructure re.sub docs, clarify aspects of
- `flags` are only relevant when `pattern` is a string (followup to python#119960).
- Moved simplest "beans and spam" example from under "repl is a function"
(which it wasn't!) close to start, extended to demonstrate
both string & re.compile flags usage, and `\1` templating.
- Discuss all how-we-match parameters before what-we-do-with-matches.
TODO: Is important info close enough to start?
- Explain callback before backslash notation because it's shorter but also
to promote it. IMHO, people fear it as a "last-resort escape hatch"
while it's actually *simpler* than backslashes (python#128138 is one example).
TODO: Will this order make sense after python#135992 ?
- Consolidated `repl` notation from two far-away paragraphs to one place.
- Starting from `\1` and `\g` which are the whole purpose of dealing with backslashes!
- Briefly mention `\octal` wart, 99 limit and `\g<100>` avoiding them.
- Draw attention to `\\` for getting a literal backslash.
- Clarify that *most* escapes are supported but `\x\u\U\N` aren't.
- Move "Unknown escapes of ASCII letters" *after* listing all the known ones.
- Added a note promoting raw string notation for `repl` too.repl notation1 parent 03d07dc commit 22c003b
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1089 | 1089 | | |
1090 | 1090 | | |
1091 | 1091 | | |
1092 | | - | |
| 1092 | + | |
1093 | 1093 | | |
1094 | 1094 | | |
1095 | 1095 | | |
| |||
0 commit comments