lecture21

lecture21 - PIC 40A Lecture 21: JavaScript: Regular...

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

View Full Document Right Arrow Icon
PIC 40A Lecture 21: JavaScript: Regular Expressions
Background image of page 1

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

View Full DocumentRight Arrow Icon
Regular Expressions •u s e d t o – describe specific strings or categories of strings – search for text having a certain pattern – replace one pattern found in a doc by another – check if a string abides by a certain pattern (a valid email address for example)
Background image of page 2
Patterns • delimited by forward slashes / Building blocks for patterns: • character patterns • character class patterns
Background image of page 3

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

View Full DocumentRight Arrow Icon
Character patterns • types of characters appearing in a pattern: – normal eg a b c 1 2 3 @ ~ , ! & ; – metacharacters (used in reg ex syntax) \ | / ( ) [ ] { } ^ $ * + ? . = : To match metacharacters, put a backslash \ before them in a pattern
Background image of page 4
Character Pattern Examples • /bruin/ matches the value “bruin” • /./ matches any character except \n • /\./ matches a period “ . • /\$5\.99/ matches “$5.99” • /func\(\)/ matches “func()”
Background image of page 5

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

View Full DocumentRight Arrow Icon
Character Classes • used to represent more general patterns • delimited by brackets [ ] • some are pre-defined • can be user-defined
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/15/2010 for the course PIC 40A taught by Professor Ouellette during the Winter '10 term at UCLA.

Page1 / 16

lecture21 - PIC 40A Lecture 21: JavaScript: Regular...

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

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