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:
- Navigate to Source > Schema > Column (whichever column you want to apply the transformation to) > Add Transformations > Add String Replacement.
- 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.
You can have more than one String Replacement on more than one 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
Connections UI
Source Table
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
Connections UI
Source Table
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:
"$&"
Connections UI
Source Table
Destination Table