teaching machines

CS 330 Lecture 4 – State Machines and Regular Expressions

January 30, 2013 by . Filed under cs330, lectures, spring 2013.

Agenda

TODO

Program This

Draw a state machine that accepts numbers that

Code

email_list.rb

#!/usr/bin/env ruby

text = IO.read(ARGV[0])
list = ""

text.scan(/[A-Z]{2,}/) do |match|
  list += $& + "@uwec.edu,"
end

puts list

strip_html.rb

#!/usr/bin/env ruby

text = IO.read(ARGV[0])
text = text.gsub(/<.*?>/, '')
puts text

Haiku

It’s all legal there.
In .*, anything goes.
One accepting state.