Get string or substring function (has() function)

The has() function searches for a substring within a string, or searches a string based on a regular expression.  This function can be used with either 2 or 3 parameters.   If only the first 2 parameters are specified, the function will execute as a substring search of a string. The optional third parameter, "searchByRegex" tells the function how to execute and is a Boolean value – either true or false.  If the third parameter is false, then the function executes as a substring search of a string; If the third parameter is true, then the function executes as a string search based on a regular expression.  

Regex syntax restrictions

Note the following Regex syntax restrictions:

o        Backslashes in expression rules must be paired with another backslash. For example,  has("\\d.\\d\\p{Lower}hz", clockspeed, true)

o        The "has" function does not support Groups and Capturing as described in the Java 6 javadoc.

For more information regarding the use of Regex syntax, reference the following link: http://download.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html

Format:

Boolean has(String substring, String fullstring)

Boolean has(String regex, String fullstring, Boolean searchByRegex)

where:

substring - string to search for in the fullstring

regex - regular expression to search by

fullstring - string to search

searchByRegex - OPTIONAL; true if searching by regular expression

Example:

The following example returns true when the variable errorcode contains the text "error 318" :

has("error 318", errorcode)

The following example returns true when the variable errorcode contains the text "error 31x" where x is a number from 0-9 :

has("error 31[0-9]", errorcode, true)