com.bramosystems.oss.player.util.client
Class RegExp

java.lang.Object
  extended by com.google.gwt.core.client.JavaScriptObject
      extended by com.bramosystems.oss.player.util.client.RegExp

public class RegExp
extends com.google.gwt.core.client.JavaScriptObject

Utility class for regular expressions

Since:
1.1
Author:
Sikirulai Braheem

Nested Class Summary
static class RegExp.RegexException
          Thrown to indicate a regular expression related exception
static class RegExp.RegexResult
          The RegExpResult wraps the result of the search performed by the exec(java.lang.String) method
 
Constructor Summary
protected RegExp()
          Create a new RegExp object
 
Method Summary
 RegExp.RegexResult exec(String exp)
          Performs a search for the regular expression on the specified exp
 int getLastIndex()
          Returns the index position at which the next search starts.
static RegExp getRegExp(String pattern, String flags)
          Returns a RegExp instance for the specified pattern and flags.
 String getSource()
          Returns the pattern of the regular expression
 boolean isGlobal()
          Checks if this RegExp object performs a global match.
 boolean isIgnoreCase()
          Checks if this RegExp object performs a match without case sensitivity
 boolean isMultiline()
          Checks if this RegExp object performs multiline matching.
 void setLastIndex(int lastIndex)
          Sets the index position at which to start the next search.
 boolean test(String exp)
          Tests for the match of the regular expression in the specified exp.
 
Methods inherited from class com.google.gwt.core.client.JavaScriptObject
cast, createArray, createFunction, createObject, equals, hashCode, toSource, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegExp

protected RegExp()
Create a new RegExp object

Method Detail

getRegExp

public static final RegExp getRegExp(String pattern,
                                     String flags)
                              throws RegExp.RegexException
Returns a RegExp instance for the specified pattern and flags.

The flags can include the following:

Parameters:
pattern - the pattern of the regular expression
flags - the modifiers of the expression
Returns:
the RegExp instance
Throws:
RegExp.RegexException - if any error occurs, such as invalid flags

isGlobal

public final boolean isGlobal()
Checks if this RegExp object performs a global match. A match is global if all matches are found rather than stopping after the first match

Returns:
true if the global property is set, false otherwise

isIgnoreCase

public final boolean isIgnoreCase()
Checks if this RegExp object performs a match without case sensitivity

Returns:
true if the ignoreCase property is set, false otherwise

isMultiline

public final boolean isMultiline()
Checks if this RegExp object performs multiline matching.

Returns:
true if the multiline property is set, false otherwise

getLastIndex

public final int getLastIndex()
Returns the index position at which the next search starts.

Returns:
the index position
See Also:
setLastIndex(int)

setLastIndex

public final void setLastIndex(int lastIndex)
Sets the index position at which to start the next search. This property affects the exec(java.lang.String) and test(java.lang.String) methods.

Parameters:
lastIndex - the new index position

getSource

public final String getSource()
Returns the pattern of the regular expression

Returns:
the pattern of the regular expression

test

public final boolean test(String exp)
Tests for the match of the regular expression in the specified exp.

Returns:
true if there is a match, false otherwise

exec

public final RegExp.RegexResult exec(String exp)
                              throws RegExp.RegexException
Performs a search for the regular expression on the specified exp

Parameters:
exp - the string to search
Returns:
the result of the search
Throws:
RegExp.RegexException - if there is no match


Copyright © 2009-2011. All Rights Reserved.