'Why re.findall does not find the match in this case? [duplicate]

I'm trying to reconstruct an example string from a given regular expression

test_re = r'\s([0-9A-Z]+\w*)\s+\S*[Aa]lloy\s'

However, the code below only gives ['1AZabc']

import re 
txt = " 1AZabc sdfsdfAlloy "
test_re = r'\s([0-9A-Z]+\w*)\s+\S*[Aa]lloy\s'
# test_re = r'\s+\S*[Aa]lloy\s'
x = re.findall(test_re,txt)
print(x)

Why the contents after the space (for matching the \s+) is not captured by re? What is a simple and valid example string that matches the text_re?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source