Skip to content

Remove HTML Tags from a String in a Flow #1072

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This code will be helpful to those who are looking out to remove HTML tags and convert it to String variable within the Flow Designer. The Replace String transformation function doesn't works well with the HTML variable so to overcome this challenge, we can make use of a Run Script Flow action along with a regex and JavaScript replace method.

The function expects the input HTML string to be passed into and we get a string free from HTML tags and whitespaces as an output.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(function execute(inputs, outputs) {
var htmlString = inputs.htmlValue; // Assuming HTML string is stored in the input variable htmlValue
var plainText = htmlString.replace(/<[^>]+>/g,''); // Regex to replace HTML tags
outputs.plainString = plainText.trim(); // Trimming the whitespaces, if any and pushing the string without HTML to output variable plainString
})(inputs, outputs);
1 change: 1 addition & 0 deletions Flow Actions/Remove HTML Tags from a String in a Flow
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading