Suppose I have String
myString = "Keyword abckeyword abc blah"
I want to capture occurence of both keyword and value immediately following keyword until white space
myregex = re.compile(fr"({keyword})\s*(\S+)", re.MULTILINE | re.IGNORECASE)
for m in myregex.finditer(myString):
print(m)
I get result as keyword abckeyword, but second match is not captured. How do I fix this ?
<_sre.SRE_Match Object; span=(0,17), match='keyword abckeyword'>
Expected result :
<_sre.SRE_Match Object; span=(0,17), match='keyword abckeyword'>
<_sre.SRE_Match Object; span=(11,21), match='keyword abc'>