It's All About the Platform.

Useful Groovy String Functions

Guest Author


Groovy Script is underpinned by Java within which there are classes and functions that are available for use within groovy. There are certain functions in the String java class that are useful when trying to process form field data. This blog post aims to go through some of those methods and explain how they can be used in the context of groovy and Application Composer.

Simple String functions

The String class comes with some standard functions that we can use to manipulate a string value input by an end user. Here is a list of them.

String Function
Sample Description
myStringVar.contains(<someOtherValue>) Returns true if and only if this string contains the specified sequence of char values.
myStringVar.equals(<someOtherValue>) This is similar to the above but has to be an exact match for the check to return a true value
myStringVar.endsWith(<suffix>) This method checks the new value contains an ending string
myStringVar.startsWith(<prefix>) This method checks the new value contains an starting string
myStringVar.equalsIgnoreCase(<someOtherValue>) The same as equals but without case sensitivity
myStringVar.isEmpty() Checks if myStringVar is populated or not.
myStringVar.matches(<someOtherValue>) this is the same as equals with the slight difference being that matches takes a regular string as a parameter unlike equals which takes another String object
myStringVar.replace(<oldVal>,<newVal>) Returns a string resulting from replacing all occurrences of oldChar in this string with newChar
myStringVar.replaceAll(<oldValRegex>,<newVal>) Replaces each substring of this string that matches the given regular expression with the given replacement
myStringVar.split(<regexPattern>) Splits this string around matches of the given regular expression


During field validation the variable newValue is the parameter name used to retrieve the field value after a form is submitted. Similarly oldValue is the previously stored value during field validation. Either or both of these variableNames would be used instead of myStringVar when performing field validation.

Further Information

Here are some related links...

Join the discussion

Comments ( 3 )
  • DJ Monday, September 18, 2017
    Should it be myStringVar.endsWith and not myStringVar.endsWidth?
  • Oliver Steinmeier Monday, September 18, 2017
    Yes, you are absolutely right, DJ. I have fixed the mistake. Thanks for pointing it out.

    Fusion Apps Developer Relations
  • Jesse Chisholm Thursday, July 12, 2018
    To get a caseless `contains`, use:

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.