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.

Constructors

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.