|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.gwt.regexp.shared.RegExp
public class RegExp
A class for regular expressions with features like Javascript's RegExp, plus Javascript String's replace and split methods (which can take a RegExp parameter). The pure Java implementation (for server-side use) uses Java's Pattern class, unavailable under GWT. The super-sourced GWT implementation simply calls on to the native Javascript classes.
There are a few small incompatibilities between the two implementations. Java-specific constructs in the regular expression syntax (e.g. [a-z&&[^bc]], (?<=foo), \A, \Q) work only in the pure Java implementation, not the GWT implementation, and are not rejected by either. Also, the Javascript-specific constructs $` and $' in the replacement expression work only in the GWT implementation, not the pure Java implementation, which rejects them.
Method Summary | |
---|---|
static RegExp |
compile(java.lang.String pattern)
Creates a regular expression object from a pattern with no flags. |
static RegExp |
compile(java.lang.String pattern,
java.lang.String flags)
Creates a regular expression object from a pattern using the given flags. |
MatchResult |
exec(java.lang.String input)
Applies the regular expression to the given string. |
boolean |
getGlobal()
Returns whether the regular expression captures all occurrences of the pattern. |
boolean |
getIgnoreCase()
Returns whether the regular expression ignores case. |
int |
getLastIndex()
Returns the zero-based position at which to start the next match. |
boolean |
getMultiline()
Returns whether '$' and '^' match line returns ('\n' and '\r') in addition to the beginning or end of the string. |
java.lang.String |
getSource()
Returns the pattern string of the regular expression. |
static java.lang.String |
quote(java.lang.String input)
Returns a literal pattern String for the specified
String . |
java.lang.String |
replace(java.lang.String input,
java.lang.String replacement)
Returns the input string with the part(s) matching the regular expression replaced with the replacement string. |
void |
setLastIndex(int lastIndex)
Sets the zero-based position at which to start the next match. |
SplitResult |
split(java.lang.String input)
Splits the input string around matches of the regular expression. |
SplitResult |
split(java.lang.String input,
int limit)
Splits the input string around matches of the regular expression. |
boolean |
test(java.lang.String input)
Determines if the regular expression matches the given string. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static RegExp compile(java.lang.String pattern)
pattern
- the Javascript regular expression pattern to compile
java.lang.RuntimeException
- if the pattern is invalidpublic static RegExp compile(java.lang.String pattern, java.lang.String flags)
pattern
- the Javascript regular expression pattern to compileflags
- the flags string, containing at most one occurrence of 'g'
(getGlobal()
), 'i'
(getIgnoreCase()
),
or 'm'
(getMultiline()
).
java.lang.RuntimeException
- if the pattern or the flags are invalidpublic static java.lang.String quote(java.lang.String input)
String
for the specified
String
.
This method produces a String
that can be used to
create a RegExp
that would match the string
s
as if it were a literal pattern.
input
- The string to be literalized
public MatchResult exec(java.lang.String input)
getLastIndex()
if the global flag is set.
input
- the string to apply the regular expression to
null
public boolean getGlobal()
public boolean getIgnoreCase()
public int getLastIndex()
exec(String)
or test(String)
, this method returns
the next position following the most recent match.
getGlobal()
public boolean getMultiline()
public java.lang.String getSource()
public java.lang.String replace(java.lang.String input, java.lang.String replacement)
input
- the string in which the regular expression is to be searched.replacement
- the replacement string.
java.lang.RuntimeException
- if replacement
is invalidpublic void setLastIndex(int lastIndex)
public SplitResult split(java.lang.String input)
input
- the string to be split.
public SplitResult split(java.lang.String input, int limit)
input
- the string to be split.limit
- the maximum number of strings to split off and return,
ignoring the rest of the input string. If negative, there is no
limit.
public boolean test(java.lang.String input)
getLastIndex()
if the global flag is
set. Equivalent to: exec(input) != null
input
- the string to apply the regular expression to
|
GWT 2.7.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |