CSE 101 Lecture Notes - Lecture 14: Social Security Number, Regular Expression, Metacharacter

38 views4 pages

Document Summary

Pattern is a format that ensures that a string matches a particular format. Computer programmers, web designers and others often use regular expressions (regexes) for writing such patterns. The notation for regular expressions is like a language unto itself. This would match occurrences of cse in these strings. So a generic social security number could be expressed as \d\d\d-\d\d-\d\d\d\d using regexes. {5} would match a 5-character sequence of any characters: If you want to match an actual period, you escape it: \. \d{3}\. \d{3}\. \d{4} will match phone numbers written in a form like. Matching specific characters dot metacharacter matches any character. We can match specific characters using regexes by defining them inside square brackets. [abc] will match a single a, b, or c letter and nothing else. To exclude specific characters, we use the square brackets and the ^ (hat) character. [^abc] will match any single character except letters a, b, or c.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers