Python regular expressions - how to capture multiple groups from a wildcard expression?
问题 I have a Python regular expression that contains a group which can occur zero or many times - but when I retrieve the list of groups afterwards, only the last one is present. Example: re.search("(\w)*", "abcdefg").groups () this returns the list ('g',) I need it to return ('a','b','c','d','e','f','g',) Is that possible? How can I do it? 回答1: In addition to Douglas Leeder's solution, here is the explanation: In regular expressions the group count is fixed. Placing a quantifier behind a group