Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python regular expressions to return complete result

Tags:

python

regex

How can I get what was matched from a python regular expression?

re.match("^\\\w*", "/welcome")

All python returns is a valid match; but I want the entire result returned; how do I do that?

like image 736
nobody Avatar asked Dec 09 '25 03:12

nobody


1 Answers

Just use re.findall function.

>>> re.findall("a+", 'sdaaddaa')
['aa', 'aa']
like image 167
Roman Bodnarchuk Avatar answered Dec 10 '25 17:12

Roman Bodnarchuk