I&C SCI 33 Lecture 6: [Regex II]
Premium

2 Pages
50 Views

Department
Information and Computer Science
Course Code
I&C SCI 33
Professor
Richard Pattis

This preview shows 80% of the first page. Sign up to view the full 2 pages of the document.
Description
Lecture 6 [Regex II]  Friday, April 14, 2017  9:46 AM  *Generally, the functions discussed in this lecture operate on a regular expression pattern (specified by a string) and text (also specified by a string).    re functions: called like re.match(...) the module name prefaces the function  • Returns a regex (compiled pattern) object (see calling methods on regex below)  compile(pattern, Creates compiled pattern object  [,flags])    • Returns a match object, consisting of tuple of groups (0,1,...)  match(pattern, Matches start at the text's beginning  text [,flags])  search(pattern, Matches can start anywhere in the text  text [,flags])    • Returns a list of string/of tuples of string (the groups), specifying matches  findall(pattern, Matches can start anywhere in the text; the next attempted text [,flags])  match starts one character after the previous match terminates.    • Returns a iterable of the information returned by findall (ignore this one)  finditer(pattern, Returns iterable equivalent of findall  text [,flags])    • Returns a list of strings: much like calling text.split(...)  split(pattern, like the text.split(...) method, but using a regular text [,maxsplit, expressions pattern to determine how to split the text: flags])  re.split('\.|­', 'a.b­c') returns ['a','b','c']    • Returns a string  sub(pattern, repl, in text, replace pattern by repl (which may refer to matched text, [,count, groups via \# (e.g. \1) or \g, (e.g., \g<1>), or \g flags])  (where name comes from ?P) or a function that is passed a match object); if there is no match, then it just returns
More Less
Unlock Document

Only 80% of the first page are available for preview. Some parts have been intentionally blurred.

Unlock Document
You're Reading a Preview

Unlock to view full version

Unlock Document

Log In


OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit