1 / 14

CGS – 4854 Summer 2012

CGS – 4854 Summer 2012 . Instructor: Francisco R. Ortega Chapter 5 Regular Expressions. Web Site Construction and Management. Today’s Lecture. Chapter 5 Regular Expressions Talk about tutorial 4 and homework 4 Help with homework #4. Mid-Term. Mid-Term June 21 st .

usoa
Download Presentation

CGS – 4854 Summer 2012

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CGS – 4854 Summer 2012 Instructor: Francisco R. Ortega Chapter 5 Regular Expressions Web Site Construction and Management

  2. Today’s Lecture • Chapter 5 Regular Expressions • Talk about tutorial 4 and homework 4 • Help with homework #4

  3. Mid-Term • Mid-Term June 21st. • Chapters 1,2,3 and 4. • Possible review for mid-term • June 14 (after quiz 4) or June 19 • Extra Credit for Mid-Term • Extra credit question may be Java related or Regular Expressions (if covered before the exam) • You are allowed to bring one letter size paper to the exam

  4. ASCII Table (Part 1)

  5. Regular Expressions • Match strings of text (wiki) • Sequence of regular expressions is known as a pattern • Regular expressions contain • Wildcards • Special characters • Escape sequences

  6. Regular Expressions 101 • Characters match themselves except: [\^$.|?*+() • \ suppresses the meaning of special characters • [] starts a character class. We match one from the class. • - specifies a range of characters • ^ negates a character class • . matches any single character except line break • | matches either the left, or the right (or)

  7. Character Classes • [xyz] : will match x or y or z • [a-z] : will match lowercase letters • [a-zA-Z] : will match all letters • [a-Z] :will not match any letters (why?) • [A-z] : will match all letters but additional symbols. Why? • [^abc] : Any character except for a,b or c.

  8. Predefined classes

  9. Escape Sequence • \. : would match a period • [.] : would match a period • \ does not lose special meaning inside square brackets [\d]

  10. Alternation • yes|no • yes|no|maybe • It will match either yes,no or maybae. • But only one of them.

  11. Grouping and Capturing • (pattern) • Capturing pattern. • Can retrieve values from \1 thru \9 • Example • Text: abyes3 • [a-z] ([a-z]) (yes|no) \d • \1 is equal to b • \2 is equal to yes • (?:pattern) • Only used for grouping

  12. Ignoring case • (?i)yes|no • [yY] [eE] [sS] | [Nn] [Oo]

  13. Repetition

  14. Regex in java • You will need to use two backslashes • Regex: \d • Java regex: “\\d”

More Related