Pre-defined Objects Regular Expressions
Pre-defined Objects: RegExp
•
There is a range of special characters that match characters other than
themselves or have special meaning
^ Matches beginning of input/line
$ Matches end of input/line
+ Matches the preceding expression 1 or more times
* Matches the preceding expression 0 or more times
[set] Matches any character in set which consists of
characters, special characters and ranges of characters
[^set] Matches any character not in set
/^[ a -z ]+ $ / m atc hes " abc ", "x"
but not "0 abc " , " abc1 " , " ab " , " AB ", ""
/^\ s *[a -z ]+\ s *$ / ma tches " abc " , "x ", " ab "
but not "0 abc " , " abc1 " , " AB " , ""
/^[^ a - z ]+ $ / matches " AB " , "0123"
but not " abc ", "x" , "0 abc "
COMP519 Web Programming Lecture 15 Slide L15 – 21