ID EN
Regular Expression

start

Python 3.11

Return the indices of the start and end of the substring matched by group; group defaults to zero (meaning the whole matched substring). Return -1 if group exists but did not contribute to the match. For a match object m, and a group g that did contribute to the match, the substring matched by group g (equivalent to m.group(g)) is

Syntax

PYTHON
Match.start([group])

Examples

Example 1
PYTHON
m.string[m.start(g):m.end(g)]
Example 2
PYTHON
>>> email = "tony@tiremove_thisger.net"
>>> m = re.search("remove_this", email)
>>> email[:m.start()] + email[m.end():]
'tony@tiger.net'

See Also

IndexError