regex - Python get the smallest words between two characters -
how find smallest string between 2 characters in python. tried extract words between [[
, ]]
, put them list:
clause_text ="bien_id [[bien_id.name]] dossier [[dossier_id.name]] " list_variables = re.findall(re.escape("[[")+"(.*)"+re.escape("]]"),clause_text) print list_variables
in case need 2 variables on list bien_id.name
, dossier_id.name
but result 1 variable:
[u'bien_id.name]] dfdfdf [[dossier_id.name']
it means takes biggest word between brackets.can me please solve problem?
you looking non-greedy regex. use (.*?)
instead of (.*)
Comments
Post a Comment