Wk9_RegExp-4pp

Cted watches its me gregexpralphadigitpunct alpha

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ery St Frances || ||| Found S________|| ||| Followed by t?__| No ||| Is it S?________| No ...||| Keep looking for S Found S_________________||| Followed by t?___________|| Yes Followed by a blank?______| Yes - A match! 
 > gsub("St ", "St. ", cNames) [1] "Dewitt County" [2] "Lac qui Parle County" [3] "St. John the Baptist Parish" [4] "Stone County" 
 > strings = c("a test", "and one and one is two", + "one two three") > gsub("one", "1", strings) [1] "a test" "and 1 and 1 is two" "1 two three" > sub("one", "1", strings) [1] "a test" "and 1 and one is two" "1 two three" Regular
Expressions
to
the
 Rescue
 8
 10/18/12
 Regular
Expressions
 •  Regular
expressions
give
us
a
powerful
way
of
 matching
paNerns
in
text
data
 •  Most
importantly,
we
do
this
all
 programa5cally
rather
than...
View Full Document

Ask a homework question - tutors are online