Joshua
open source statistical hierarchical phrase-based machine translation system
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
joshua.util.Regex Class Reference
Collaboration diagram for joshua.util.Regex:
[legend]

List of all members.

Public Member Functions

 Regex (String regex) throws PatternSyntaxException
final boolean matches (String input)
final String[] split (CharSequence input)
final String[] split (CharSequence input, int limit)
final String replaceAll (String input, String replacement)
final String replaceFirst (String input, String replacement)

Static Public Attributes

static final Regex commentOrEmptyLine = new Regex("^\\s*(?:\\#.*)?$")
static final Regex floatingNumber = new Regex("^[\\d\\.\\-\\+]+")
static final Regex spaces = new Regex("\\s+")
static final Regex tabs = new Regex("\\t+")
static final Regex equalsWithSpaces = new Regex("\\s*=\\s*")
static final Regex threeBarsWithSpace = new Regex("\\s\\|{3}\\s")

Private Attributes

final Pattern pattern

Detailed Description

This class provides a repository for common regex patterns so that we don't keep recompiling them over and over again. Some convenience methods are provided to make the interface more similar to the convenience functions on String. The convenience methods on String are deprecated except for one-shot patterns (which, by definition, are not in loops).

Author:
wren ng thornton wren@.nosp@m.user.nosp@m.s.sou.nosp@m.rcef.nosp@m.orge..nosp@m.net
Version:
LastChangedDate:
2009-03-28 07:40:25 -0400 (Sat, 28 Mar 2009)

Constructor & Destructor Documentation

joshua.util.Regex.Regex ( String  regex) throws PatternSyntaxException

Member Function Documentation

final boolean joshua.util.Regex.matches ( String  input)

Returns whether the input string matches this Regex.

Here is the caller graph for this function:

final String joshua.util.Regex.replaceAll ( String  input,
String  replacement 
)

Replace all substrings of the input which match this Regex with the specified replacement string.

Here is the caller graph for this function:

final String joshua.util.Regex.replaceFirst ( String  input,
String  replacement 
)

Replace the first substring of the input which matches this Regex with the specified replacement string.

final String [] joshua.util.Regex.split ( CharSequence  input)

Split a character sequence, removing instances of this Regex.

Here is the caller graph for this function:

final String [] joshua.util.Regex.split ( CharSequence  input,
int  limit 
)

Split a character sequence, removing instances of this Regex, up to a limited number of segments.


Member Data Documentation

final Regex joshua.util.Regex.commentOrEmptyLine = new Regex("^\\s*(?:\\#.*)?$") [static]

A pattern to match if the complete string is empty except for whitespace and end-of-line comments beginning with an octothorpe (#).

final Regex joshua.util.Regex.equalsWithSpaces = new Regex("\\s*=\\s*") [static]

A pattern for splitting on the equals character, with optional whitespace on each side.

final Regex joshua.util.Regex.floatingNumber = new Regex("^[\\d\\.\\-\\+]+") [static]

A pattern to match floating point numbers. (Current implementation is overly permissive.)

final Pattern joshua.util.Regex.pattern [private]
final Regex joshua.util.Regex.spaces = new Regex("\\s+") [static]

A pattern for splitting on one or more whitespace.

final Regex joshua.util.Regex.tabs = new Regex("\\t+") [static]

A pattern for splitting on one or more whitespace.

final Regex joshua.util.Regex.threeBarsWithSpace = new Regex("\\s\\|{3}\\s") [static]

A pattern for splitting on three vertical pipes, with one or more whitespace on each side.