import re s = "xaz xazx xaxsza zsxdaszdx zasxz xaaz xaaaz"pattern = r"\bx\w*z\b"print(re.findall(pattern, s))
Standard input is empty
['xaz', 'xaaz', 'xaaaz']
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!