Skip to main content

         This documentation site is for previous versions. Visit our new documentation site for current releases.      

Sample Robotic Automation solution: City State ZIP regex - Splitting an array

Updated on September 10, 2021

This sample solution shows how to use a StringUtils component from the Advanced tab of the Toolbar to get the City, State, and ZIP from a single line of text by using Pega Robot Studio.

A StringUtils component is used to return an array of the City, State, and ZIP information, and then the automation breaks the array apart by using a StringArrayProxy object.

Project items

  • Windows form: User Interface
  • Automation: RegEx Example Stripping out an Address

Automation details

The logic is triggered when you click the Break Apart into Three button on the Windows form.

The entry from the txtWholeAddress text box is sent to the StringUtils RegexReplace method where the regular expression (regex) syntax removes the commas and spaces in the input text string and separates the text with exclamation points (!). For example: Indiana, TX 56473 returns as Indiana!TX!56473. For more information on the syntax, see Special considerations.

The result of the RegexReplace method is then passed to a StringUtils Split method where the string is split into an array. The items are split based on the position of the exclamation points in the text string.

A proxy is created for the StringArray result. The Get method for the StringArrayProxy object is used to return the value of each array member beginning with member at index zero (0) – the first item.

Special considerations

The following image displays the regex syntax that is used with the RegexReplace method. Note that the input for the method contains text that is separated by a comma and spaces: City, ST ZIP. The ZIP code is optional. To represent this in Regex syntax, the commas and spaces in the text string are used to group the text.

An example of the Regex syntax

Where "\w" represents words and "\s" represents spaces.

The replacement string removes any spaces or commas and inserts exclamation points before words 2 and 4. Therefore, the replacement syntax is:$1!$2!$4

You can download completed solutions for each version in the following table:

Studio versionBuilt by using this buildSample solution download Regex - Splitting 8.0
8.0 SP18.0.2037Address Regex - Splitting 8.0 SP1 Regex - Splitting 19.1
  • Previous topic Sample Robotic Automation solution: Cancel event
  • Next topic Sample Robotic Automation solution: File access


Robotics System Architect Robotic Process Automation

Have a question? Get answers now.

Visit the Support Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best. is not optimized for Internet Explorer. For the optimal experience, please use:

Close Deprecation Notice
Contact us