4834_lecture_26_ho

4834_lecture_26_ho - EEL 4834: Lecture 26 EEL 4834: Lecture...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
EEL 4834: Lecture 26 EEL 4834: Lecture 26 Regular Expressions Professor O. Boykin University of Florida, Department of Electrical and Computer Engineering November 3, 2009 EEL 4834: Lecture 26 Recognizing Patterns in Text Often we have some text has some pattern: f1.2 nothing happened g44 some other stuff h823.4 some notes here The above seems to follow the pattern of a letter, followed by some decimal number without spaces, followed by some string of text. Regular expressions are a way of describing such patterns (and much more complex ones).
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
EEL 4834: Lecture 26 Very simple example import re regexp = "body" string = "you all everybody" if re.search(regexp, string): print "there is a body in our string" EEL 4834: Lecture 26 Another example import re s = [ "this string has a caaaat" , "this string has no ct" ] for t in s: if re.search( "ca+t" ,t): print ’"%s" has cat’ % t else: print ’"%s" has no cat’ % t
Background image of page 2
EEL 4834: Lecture 26 More complex example Look at this data file: Sun Nov 11 21:42:12 2007 99999.99 0.73 0.9798 99 0
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/11/2010 for the course EEL 4834 taught by Professor Staff during the Fall '08 term at University of Florida.

Page1 / 8

4834_lecture_26_ho - EEL 4834: Lecture 26 EEL 4834: Lecture...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online