# Names: Judy Franklin, Jean-Luc Ponty, and Stanley Clarke # Class: csc250 # Contents: functions and text answers for relab # Date: February 20, 2012 import reDon't forget to put in the import re statement to import the re functions. Use python function definitions to test your regular expressions. This is easier than retyping and editing on the python interpreter command line. You will submit this file electronically, by Friday February 18, class time, by typing
rsubmit relab relab.py
>>> as = r'<html><title> The spring 2011 foundations class</title></html>'as well as
>>> as = r'<body><h3> The spring 2011 foundations class</H3></BODY>'Don't forget to turn off case sensitivity.
>>> match = re.search(r'<([A-Z][A-Z0-9]*)[^>]*>(.*?)</\1>', as, re.IGNORECASE)and typed both
>>> print match.groups(0) or >>> print match.group(0) and >>> print match.group(1)to see the results. Do this in a function definition in python, in your file called relab.py.
# \b is a word boundary # \d{1,3} indicates between 1 and 3 digits # etc.In the IP address example on the same examples web site, http://www.regular-expressions.info/examples.html, explain exactly how the three regular expressions work:
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b2.
\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\. (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b(all on one line)
\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b
# use python's comments to answer the text # part of this homework.
rsubmit relab relab.py