expr = "name + partner_id.country_id.name + city + ' ' + 123 + '123' + 12*2/58%45"
print re.findall('\w+[.]',expr)
['name',
'partner_id',
'country_id',
'name',
'city',
'123',
'123',
'12',
'2',
'58',
'45']
I want to include “.” so result should be like
['name',
'partner_id.country_id.name',
'city',
'123',
'123',
'12',
'2',
'58',
'45']
Try the regex:
Explanation:
[...]is the char class\wis a char of a word, short for[a-zA-Z0-9_].is generally a meta char to matchany char but inside a char class its
treated as a literal
.+for one or more