Mastering Python Regular Expressions by López Félix; Romero Víctor;

Mastering Python Regular Expressions by López Félix; Romero Víctor;

Author:López, Félix; Romero, Víctor;
Language: eng
Format: epub, pdf
Publisher: Packt Publishing


end([group])

The end operation behaves exactly the same as start, except that it returns the end of the substring matched by the group:

>>> pattern = re.compile(r"(?P<first>\w+) (?P<second>\w+)?") >>> match = pattern.search("Hello⇢") >>> match.end (1) 5

span([group])

It's an operation that gives you a tuple with the values from start and end. This operation is often used in text editors to locate and highlight a search. The following code is an example of this operation:

>>> pattern = re.compile(r"(?P<first>\w+) (?P<second>\w+)?") >>> match = pattern.search("Hello⇢") >>> match.span(1) (0, 5)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.