Strip out HTML tags in JavaScript
November 17, 2016
Tags: ServiceNow Strip HTML tags Server Script JavaScript
In cases where you’re getting information from external sources, you may need to strip out HTML tags.
The code below does the following:
- Removes all HTML tags over multiple lines
- Splits the string into an array of strings, each string represents a line
- All
codes are replaced with their text alternatives - Empty lines are removed
- Turn the array back into a string and return the result
Regular expression is taken from this StackOverflow post