Skip to main content

String Replacement

You can configure a string replacement transformation on your incoming data by using .NET regular expressions.

Using Regex, you can define a data pattern that Cinchy will look for in your source. If found, it will perform a string replacement with whatever new data you define.

Connections string replacements use the .NET regular expression language.

In the Connections UI

To add a Transformation > String Replacement via the Connections Experience:

  1. Navigate to Source > Schema > Column (whichever column you want to apply the transformation to) > Add Transformations > Add String Replacement.
  2. Input the following:
  • The Pattern for your string replacement, using .NET Regular Expression language.
  • The Replacement string to input when your pattern returns as true.
info

You can have more than one String Replacement on more than one column.

Image 1: Standard Column

Examples

This section covers some common examples that you might find useful when configuring your string replacement. The .NET language used can be reviewed here.

Example 1

Replacing a single character or character string.

Use Case: A source table column, "Deadline", has the following values: Q1, Q2, Q3,.... When syncing into the destination table, we want to transform it to Quarter 1, Quarter 2, Quarter 3,... instead.

The below pattern searches for any instance of the character "Q" and replaces it with "Quarter".

  • Pattern: Q\.?
  • Replacement: Quarter

Example1 Connections UI

Example1 Source Table

Example1 Destination Table

Example 2

Removing extra whitespace.

Use Case: A source table column, "Description", has text that includes extra whitespace between words. When syncing into the destination table, we want to remove any additional whitespace.

The below pattern searches for all whitespace and replaces it with a single space.

  • Pattern: \s+
  • Replacement: Use a whitespace character as the value

Example2 Connections UI

Example2 Source Table

Example2 Destination Table

Example 3

Adding a character to the beginning and ending of a match.

Use Case: A source table column, "Name", has a list of documentation page names. When syncing into the destination table, we want to add quotation marks around the names.

The below pattern searches for a pattern of one or more word characters, followed by zero or one whitespace characters, and adds literal quotation marks to the beginning and end.

  • Pattern: ^(\w+\s?)+$
  • Replacement: "$&"

Example3 Connections UI

Example3 Source Table

Example3 Destination Table