Skip to main content
Skip table of contents

findPattern() Operation


Syntax
NONE
set result = aString.findPattern(regExpPattern)
set result = findPattern(LITERAL, regExpPattern)
SemanticsReturns the first occurrence of the pattern found in aString. Raises an error if the pattern is not found. Returns a new string. The state of the current string is not changed.
SubstitutablesaString Can be any variable or object attribute having the type String.  
regExpPattern Regular expressions (see Regular Expressions for a list of valid regular expressions). An introduction into regular expressions can be found at http://www.regular-expressions.info/.
LITERAL String literal.
Error CodesFind the related error codes on System Errors of string operations.
FUSSM/21Cannot find any occurrences of pattern <pattern> in string <string>.
Examples

This example returns result = X in this phrase.

NONE
set s1 = "The findPattern() operation finds the X in this phrase." 
set result = s1.findPattern("X.+");

This example throws an error as there is no X in the string at all.

NONE
set s1 = "The findPattern() operation won't find the pattern." 
set result = s1.findPattern("X.+");
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.