Formal
Languages
and the
Theory of
Computation

Spring 2011
course
navigation

Feb 1

regular expressions in programming languages

Regular expressions in programming languages. For example, in python, as described at http://docs.python.org/library/re.html .
import re regex = r"^0(a|b)*1$" # an example if re.match(regex, "0abaab1"): print "yes"
Here are some of the syntax pieces: ^ string begin $ string end A,a,1,… match themselves . any single char x* 0,1,2 of x x? 0,1 of x () grouping x{m} exactly m x's x{m,n} m to n x's [abc] one char from set x|y x or y
http://cs.marlboro.edu/ courses/ spring2011/formal_languages/ notes/ Feb_1
last modified Tuesday February 1 2011 11:21 am EST