When a rich text format (RTF) field in your source application maps to a plain text field in your destination application, the destination can receive unwanted HTML or rich text markup. You can use a Handlebars expression with a regular expression to strip that markup and keep only the plain text.
Sample data
<b>Testing <u>testing </u><font size="2"> </font><font size="1">testing </font></b><a href="http://example.com" target="_blank">testing</a>
Remove the markup
This expression uses the regexReplace helper to remove HTML tags and entities from the field:
{{{regexReplace field.name "" "( |<([^>]+)>)" "ig"}}}
Replace field.name with the field you want to clean. The regular expression ( |<([^>]+)>) matches either a entity or any HTML tag, and the empty replacement value ("") removes each match. The i flag makes the match case-insensitive, and the g flag applies it to every match in the field. The triple braces ({{{ }}}) keep integrator.io from re-escaping the output.
Notes and constraints
- The pattern removes each
entirely rather than converting it to a space, so text separated only by can run together. - The pattern handles HTML tags and
only. If your data contains other HTML entities, such as&or<, add them to the regular expression so they're removed or replaced as well.