quoteAttribute function

String quoteAttribute(
  1. String text, [
  2. String quote = "\""
])

Return quotes within an attribute's value.

Implementation

String quoteAttribute(String text, [String quote = "\""]) {
	// escape and return
	return text.replaceAll(r"\", r"\\").replaceAll(quote, "\\$quote");
}