You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
8 lines
259 B
Python
8 lines
259 B
Python
5 years ago
|
import re
|
||
|
pattern = 'fox'
|
||
|
text = 'The quick brown fox jumps over the lazy dog.'
|
||
|
match = re.search(pattern, text)
|
||
|
s = match.start()
|
||
|
e = match.end()
|
||
|
print('Found "%s" in "%s" from %d to %d ' % \
|
||
|
(match.re.pattern, match.string, s, e))
|