IFB104 Lecture Notes - Lecture 8: Regular Expression, Substring, Ex-Gay Movement

91 views3 pages
13 Nov 2018
School
Course
Professor

Document Summary

Finding substrings: python"s built-in "find" method for character strings provides a way of finding fixed substrings in text: text. find(substring) It returns the position of the first occurrence of the substring in the text. It returns "-1" if the substring doesn"t occur in the text at all: the "rfind" method does the same thing but searches for the last occurrence. Finding multiple occurrences of substrings: you can also search from a particular position: text. find(substring, starting_pos, combining this capability with loops allows all occurrences of a substring to be found. In general, however, we need a more powerful way of expressing patterns if we want to find multiple occurrences of complex patterns. Finding general patterns in text using regular expressions. * is used as a wildcard to denote "everything", but in rgex, "*" is an operator which means repeat zero or more times.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents