I am trying to do a 4-line multi-line match. My code finds the first one. But not the others.
Here is the pattern:
pattern = re.compile("([a-z]+\.com\.|net\.)[.\s\S]+(Z[A-Z0-9]+)")
Here is the subject:
sub = """yahoo.com.
Public
8
Z2RVE9XGX4PFJN
google.com.
Public
7
Z2VATLWTLBDR5D
"""
Here is the complete code:
import re
pattern = re.compile("([a-z]+\.com\.|net\.)[.\s\S]+(Z[A-Z0-9]+)")
sub = """yahoo.com.
Public
8
Z2RVE9JJGX4PFJN
google.com.
Public
7
Z2VATZOPLBDR5D
"""
m = pattern.findall(sub)
print(m)
Here is the result:
[('yahoo.com.', 'Z2RVE9JJGX4PFJN')]
And finally, here is the desired result:
[('yahoo.com.', 'Z2RVE9JJGX4PFJN'), ('google.com', Z2VATZOPLBDR5D')]
Thank you.