escape function
Escapes special characters in the given text to their corresponding HTML entities.
This function replaces the characters &, ", <, and > with their corresponding HTML entities.
text: The text to escape.
Implementation
String escape(String text) {
return text
.replaceAll('&', '&')
.replaceAll('"', '"')
.replaceAll('<', '<')
.replaceAll('>', '>');
}