You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Restructure re.sub docs, clarify aspects of repl notation
- `flags` are only relevant when `pattern` is a string (followup to python#119960).
- Extended "beans and spam" example to demonstrate both string & re.compile
flags usage, `\1` templating, and moved it close to start.
- 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.
0 commit comments