Connectors

String Connector

The String connector lets you transform the text value of a variable in your PingOne DaVinci flow.

You can use the String connector to:

  • Convert strings to lowercase, uppercase, or title case

  • Convert any type of variable to a different data type

  • Concatenate two or more strings

  • Encode and decode a string

  • Search and replace text in a string

  • Generate a random string

  • Remove white space from a string

Setup

Resources

For information and setup help, see the following:

Configuring the String connector

Add the connector in DaVinci as shown in Adding a connector, then configure it as follows.

Using the connector in a flow

Changing the capitalization of a string

You can use the Convert to Lowercase, Covert to Uppercase, or Convert to Title Case capabilities to change a string’s capitalization.

For example, if your Input String is myVariableValue, you’ll get one of the following results depending on the capability you choose:

  • MYVARIABLEVALUE

  • myvariablevalue

  • Myvariablevalue

Changing the case of a string can help you to standardize values before you compare them, such as when using the Function connector.

You can use the Convert to Lowercase capability with the Concatenate capability to generate usernames. For example, you can take the inputs John and Smith and convert them to lowercase before using the Concatenate capability to convert both variables to johnsmith@example.com.

To remove an unnecessary blank space at the beginning or end of your output string, enable Remove White Space.

Changing values to another data type

You can use the Change Data Type capability to change the data of any value to a Boolean, Number, or String. For example, if your Input Value is the string true, you can convert to the boolean true. Or take the number 3 and convert to the string "3".

Changing the data type is useful for testing that the incoming data is in the correct format. For example, if you want to convert driver license numbers, such as 456123789, from a string to number, the capability will return True. However, if the capability instead receives a passport ID, such as P123456AA, it will return False (error code 400; invalid input).

No special configuration is needed. Add the capability and populate its properties according to the help text.

Concatenating two strings

The Concatenate capability lets you merge multiple strings together.

The following example takes the input strings john and smith and converts them to johnsmith@example.com:

  1. In the Input Value section, add john to the Value 1 field or click {} and select a variable from your flow that contains the string that you want to concatenate.

  2. In the Value 2, add smith or click {} and select a variable from your flow that contains the string that you want to concatenate.

  3. Click Add to include an additional field to concatenate.

    A GIF showing a user clicking the add button in the String connector’s concatenate string capability to add a field before including example text.
  4. In the new Value 3 field, add an email domain such as @example.com.

No special configuration is needed. Add the capability and populate its properties according to the help text.

Decoding or encoding a string

The Decode and Encode capabilities let you decode and encode a string from one of several formats: Base64, URL, or Base64 URL.

For example, you can take the plain text input johnsmith@example.com and encode with Base64 to am9obnNtaXRoQGV4YW1wbGUuY29t.

No special configuration is needed. Add the capability and populate its properties according to the help text.

Searching and replacing content

The Find Substring capability lets you find a substring and its index. The outputs will include a found variable which is a boolean returning true if the substring is found and an index variable which is the substring’s position in the string.

For example, if you take the string johnsmith@example.com and search for the substring exa, you get the following output:

{
   "originalValue": "johnsmith@example.com"
   "match": ["exa"]
   "index": 10
   "found": true
}

The Find and Replace capability lets you search for text using literal matching or a regular expression. For example, you could replace every instance of test with production:

  1. In the Input String field, click {} and select a variable from your flow that contains the string that you want to search for.

  2. If your original variable value has blank space at the end that you don’t want, enable Trim White Space to remove it.

  3. In the Input String field, enter the text that you want to find in the string, such as test. Alternatively, you can enter a regular expression, such as /te[xs]t/g, which will match both test and text and the /g flag will apply the change to all matches in the input string.

  4. If you entered a regular expression in the Input String field, enable Search Using Regex.

    Replace Mode is for simple matching. When Search Using Regex is enabled, the regex itself determines which matched text is replaced.

  5. In the New Value field, enter the string that you want to replace the match with, such as production.

When Search Using Regex? is enabled, the Search field accepts regular expressions in the format /<expression>/.

This uses the ECMA / JavaScript regex engine. Learn more in Regular expressions - JavaScript on the MDN site.

For example, you can mask part of a user’s email address in the user interface by entering the following regular expression: /(?<=.{2}).(?=[^@]*?@)/g.

A screen capture showing the Find and Replace capability with the example expression in the Search field.

In this example, jsmith@example.com becomes js**@example.com:

A screen capture showing the output of the example.

Generating random strings

The Generate String capability lets you create pseudorandom numeric or alphanumeric strings of a certain length. You can use this to create temporary passwords or add unique suffixes to user identifiers.

No special configuration is needed. Add the capability and populate its properties according to the help text.

Removing white space from string

The Remove White Space capability lets you remove leading or trailing white space from a variable.

No special configuration is needed. Add the capability and populate its properties according to the help text.