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?