ccs.utils
Class Regex

java.lang.Object
  extended by ccs.utils.Regex

public class Regex
extends java.lang.Object

A Regular Expression matcher with a simpilified syntax and limited functionality. The only special characters are ? (match exactly one character) and * (match 0 or more characters). * is "greedy" - it will match as many characters as it can, but will back off as required for the match to succeed. In general this behaviour gives the results you'd expect.

Historically this class implemented the matching itself; however, Java 1.4 provides a full-featured PERL-compatible Regex system with much better performance, so this class has been re-written as a wrapper around that.


Constructor Summary
Regex(java.lang.String pattern, boolean isSense)
          Create a Regex which matches the given pattern.
 
Method Summary
 java.lang.String getPattern()
          Returns the pattern.
 boolean getSense()
          Returns whether matching is case-sensitive.
 boolean matches(java.lang.String a)
          Returns whether the given string matches the current pattern, with default case-sensitivity.
static java.lang.String translate(java.lang.String src)
          Translate the simplified regex syntax used by this class into PERL5 regex syntax.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Regex

public Regex(java.lang.String pattern,
             boolean isSense)
Create a Regex which matches the given pattern.

Parameters:
pattern - The pattern to match.
isSense - whether to perform a case-sensitive match.
Method Detail

getPattern

public java.lang.String getPattern()
Returns the pattern.

Returns:
The pattern.

getSense

public boolean getSense()
Returns whether matching is case-sensitive.

Returns:
Whether matching is case-sensitive.

matches

public boolean matches(java.lang.String a)
Returns whether the given string matches the current pattern, with default case-sensitivity.

Parameters:
a - The string to check.
Returns:
Whether it matches.

translate

public static java.lang.String translate(java.lang.String src)
Translate the simplified regex syntax used by this class into PERL5 regex syntax.

Parameters:
src - The pattern in simplified syntax.
Returns:
The pattern in full syntax.