Skip to content

Instantly share code, notes, and snippets.

@mattjbarlow
Last active December 27, 2015 19:39
Show Gist options
  • Save mattjbarlow/7379139 to your computer and use it in GitHub Desktop.
Save mattjbarlow/7379139 to your computer and use it in GitHub Desktop.
Trying to match universe multiple times between START and END lines.
import re
divine_comedy = """
Test word universe should not match.
*** START ***
His glory, by whose might all things are mov'd,
Pierces the universe, and in one part
One more universe.
*** END ***
"""
search = re.compile(r'\*{3} START \*{3}.*(\buniverse\b)', re.IGNORECASE|re.DOTALL)
print "Match is: " + re.search(search, divine_comedy).group()
print "Groups are: ", re.search(search, divine_comedy).groups()
@mattjbarlow
Copy link
Author

Output I get with this is:

Match is: *** START ***
His glory, by whose might all things are mov'd,
Pierces the universe, and in one part
One more universe
Groups are:  ('universe',)
[Finished in 0.3s]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment