In Python, how do you capture a group within a non-capturing group? Put in another way, how do you repeat a non-capturing sub-pattern that contains a capturing group?
An example of this would be to capture all of the package names on an import string. E.g. the string:
import pandas, os, sys
Would return 'pandas', 'os', and 'sys'. The following pattern captures the first package and gets up to the second package:
import\s+([a-zA-Z0=9]*),*\s*
From here, I would like to repeat the sub-pattern that captures the group and matches the following characters, i.e.([a-zA-Z0=9]*),*\s*
. When I surround this sub-pattern with a non-capturing group and repeat it:
import\s+(?:([a-zA-Z0=9]*),*\s*)*
It no longer captures the group inside.