org.tagnetic.core.util
Class RegExpUtil

java.lang.Object
  extended byorg.tagnetic.core.util.RegExpUtil

public class RegExpUtil
extends java.lang.Object


Constructor Summary
RegExpUtil()
           
 
Method Summary
static java.lang.String escapeRegExpSensitiveCharacters(java.lang.String value)
           
static java.lang.String replaceFirstMatch(java.lang.String source, java.util.regex.Pattern pattern, java.lang.String replacement, java.lang.String missingMatchErrorMessage)
          This method differs from String.replaceFirst in that it will throw an exception if the pattern can't be found in the source.
static java.lang.String safeReplaceAll(java.lang.String input, java.lang.String regexp, java.lang.String replacement)
          This method differs from the String.replaceAll method in that it "escapes" the $ and \ characters in the replacement string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegExpUtil

public RegExpUtil()
Method Detail

replaceFirstMatch

public static java.lang.String replaceFirstMatch(java.lang.String source,
                                                 java.util.regex.Pattern pattern,
                                                 java.lang.String replacement,
                                                 java.lang.String missingMatchErrorMessage)
                                          throws TagneticBadDataException
This method differs from String.replaceFirst in that it will throw an exception if the pattern can't be found in the source.

Throws:
TagneticBadDataException

escapeRegExpSensitiveCharacters

public static java.lang.String escapeRegExpSensitiveCharacters(java.lang.String value)

safeReplaceAll

public static java.lang.String safeReplaceAll(java.lang.String input,
                                              java.lang.String regexp,
                                              java.lang.String replacement)
This method differs from the String.replaceAll method in that it "escapes" the $ and \ characters in the replacement string. Those are special characters used for regexp groups, but normally in tagnetic parsing, we don't use those characters for that purpose.



Copyright © 2005 tagnetic.org. All Rights Reserved.