com.taleo.integration.client.customstep.util
Class RegexUtils

java.lang.Object
  extended by com.taleo.integration.client.customstep.util.RegexUtils

public class RegexUtils
extends java.lang.Object

This class contains a static function that will escape special character used within a string to ensure that the string will not parse as a regular expression. This is important when accepting user input and then using that input within a function that accepts regular expressions as an argument. To ensure that the user's input does not interfere with the function all of the regular expression characters are escaped.

Author:
NickDMax for DreamInCode 2009

Constructor Summary
RegexUtils()
           
 
Method Summary
static java.lang.String escapeRegex(java.lang.String inStr)
          This function will escape special characters within a string to ensure that the string will not be parsed as a regular expression.
static java.lang.String escRegEx(java.lang.String inStr)
          This procedure is used to ensure that a string is not interpreted as a regular expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegexUtils

public RegexUtils()
Method Detail

escapeRegex

public static java.lang.String escapeRegex(java.lang.String inStr)
This function will escape special characters within a string to ensure that the string will not be parsed as a regular expression. This is helpful with accepting using input that needs to be used in functions that take a regular expression as an argument (such as String.replaceAll(), or String.split()).

Parameters:
inStr - - argument which we wish to escape.
Returns:
- Resulting string with the following characters escaped: [](){}+*^?$.\

escRegEx

public static java.lang.String escRegEx(java.lang.String inStr)
This procedure is used to ensure that a string is not interpreted as a regular expression. This is useful when using the String.replaceAll() or String.split() functions with user input. This will escape special characters from the input string so that it will not be interpreted as a regular expression. This alternate version does not use a precompiled pattern so it may be copied and pasted into your code as is.

Parameters:
strIn - - a string that we want to ensure does not interfere with a regular expression.
Returns:
- strIn with the following chars escaped: [](){}+*^?$.\