getQuotedText function

String getQuotedText(
  1. String text
)

Implementation

String getQuotedText(
    String text
    )
{
    final quotedText =
        text
            .replaceAll( '\\', '\\\\' )
            .replaceAll( '\n', '\\n' )
            .replaceAll( '\r', '\\r' )
            .replaceAll( '\t', '\\t' )
            .replaceAll( '"', '\\"' )
            .replaceAll( '\'', '\\\'' );

    return '"$quotedText"';
}