Constructor and Description |
---|
RegExp(String pattern)
Creates a regular expression.
See MDN RegExp. |
RegExp(String pattern,
String flags)
Creates a regular expression, using flags passed as string.
If specified, flags is a string that contains the flags to add. Alternatively, if an object is supplied for the pattern, the flags string will replace any of that object's flags (and lastIndex will be reset to 0). Flags may contain any combination of the following characters: g (global match), finds all matches rather than stopping after the first match. |
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. |
static int |
getLastIndex()
Returns the index at which to start the next match.
This property is set only if the regular expression instance used the g flag to indicate a global search, or the y flag to indicate a sticky search. The following rules apply: If lastIndex is greater than the length of the string, test(String) and exec(String) fail, then lastIndex is set to 0
If lastIndex is equal to or less than the length of the string and if the regular expression matches the empty string, then the regular expression matches input starting
from lastIndex. |
String |
getSource()
Returns a string containing the source text of the
RegExp object, and it doesn't contain the two forward slashes on both sides and any flags. |
boolean |
isDotAll()
Returns
true whether or not the "s" flag is used with the regular expression.It is a read-only property of an individual regular expression instance. |
boolean |
isGlobal()
Returns
true whether or not the "g" flag is used with the regular expression.It is a read-only property of an individual regular expression instance. |
boolean |
isIgnoreCase()
Returns
true if the "i" flag was used; otherwise, false .The "i" flag indicates that case should be ignored while attempting a match in a string. It is a read-only property of an individual regular expression instance. |
boolean |
isMultiline()
Returns
true whether or not the "m" flag is used with the regular expression.It is a read-only property of an individual regular expression instance. |
boolean |
isSticky()
Returns
true whether or not the search is sticky (searches in strings only from the index indicated by the last index property of this regular expression).It is a read-only property of an individual regular expression instance. |
boolean |
isUnicode()
Returns
true whether or not the "u" flag is used with a regular expression.It is a read-only property of an individual regular expression instance. |
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.public RegExp(String pattern, String flags)
u
flag is also enabled, uses Unicode case folding.
.
to match newlines.
pattern
- the text of the regular expression.flags
- If specified, flags is a string that contains the flags to add.u
flag is also enabled, uses Unicode case folding.
.
to match newlines.
@JsProperty public static int getLastIndex()
test(String)
and exec(String)
fail, then lastIndex is set to 0
@JsProperty public boolean isDotAll()
true
whether or not the "s" flag is used with the regular expression.true
whether or not the "s" flag is used with the regular expression@JsProperty public boolean isGlobal()
true
whether or not the "g" flag is used with the regular expression.true
whether or not the "g" flag is used with the regular expression@JsProperty public boolean isIgnoreCase()
true
if the "i" flag was used; otherwise, false
.true
if the "i" flag was used; otherwise, false
@JsProperty public boolean isMultiline()
true
whether or not the "m" flag is used with the regular expression.true
whether or not the "m" flag is used with the regular expression@JsProperty public boolean isUnicode()
true
whether or not the "u" flag is used with a regular expression.true
whether or not the "u" flag is used with a regular expression@JsProperty public boolean isSticky()
true
whether or not the search is sticky (searches in strings only from the index indicated by the last index property of this regular expression).true
whether or not the search is sticky (searches in strings only from the index indicated by the last index property of this regular expression)@JsProperty public String getSource()
RegExp
object, and it doesn't contain the two forward slashes on both sides and any flags.RegExp
object, and it doesn't contain the two forward slashes on both sides and any flags@JsMethod public RegExpResult exec(String s)
s
- string to use for matching@JsMethod public 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
.