25.27. The RegExp Object

Netscape 4.0 introduced the RegExp object to represent regular expressions and added support for it in the String object through the match, replace, search, and split methods.


new RegExp("pattern") This constructor builds a regular expression. A regular expression is a string containing some special characters that Java uses to check for occurrences of certain patterns in strings. These characters are listed in Table 25.1, but the most important three are +, which means “match one or more occurrences of the previous character”; *, which means “match zero or more occurrences of the previous character”; and ?, which means “match zero or one occurrence of the previous character.” In the absence of these special ...

Get Core Web Programming, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.