Constructor and Description |
---|
RegExp(String pattern)
Creates a regular expression.
|
RegExp(String pattern,
String flags)
Creates a regular expression.
|
Modifier and Type | Method and Description |
---|---|
RegExpResult |
exec(String s)
Executes a search for a match in a string.
It returns an array of information or null on a mismatch. |
boolean |
test(String value)
Executes a search for a match between a regular expression and a specified string.
|
public RegExp(String pattern)
pattern
- the text of the regular expression. Patterns can include special characters so they can match a wider range of values than would a literal string.public RegExp(String pattern, String flags)
pattern
- the text of the regular expression. Patterns can include special characters so they can match a wider range of values than would a literal string.flags
- If specified, flags indicates the flags to add. If flags is not specified and a regular expressions object is supplied, that object's flags (and lastIndex
value) will be copied over.public RegExpResult exec(String s)
s
- string to use for matchingpublic boolean test(String value)
value
- the string against which to match the regular expression.true
if there is a match between the regular expression and the string. Otherwise, false
.