FCF 2.0 development in progress...
> > > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

fcf.escapeQuotes() function

string fcf.escapeQuotes(string a_str, string|[string] a_quote = undefined)

Package: fcf-framework-core

File: fcf-framework-core:fcf.js

Available from version: 2.0.2

Escapes single and double quotes with \

Arguments

string a_str
- Source string

string|[string] a_quote = undefined
- If the parameter is specified and contains the value of the escaped character or an array of escaped characters, then only the specified character and the \ character are escaped.
Result
string
- String with escaped characters

Example: Function application

{ let result = fcf.escapeQuotes("test string 1: \\ \" ' "); console.log(result); } { let result = fcf.escapeQuotes("test string 2: \\ \" ' ", "\""); console.log(result); } { let result = fcf.escapeQuotes("test string 3: \\ \" ' ", "'"); console.log(result); } { let result = fcf.escapeQuotes("test string 4: \\ \" ' `", "`"); console.log(result); } { let result = fcf.escapeQuotes("test string 5: \\ \" ' `", ["\"", "'", "`"]); console.log(result); }

Output:

test string 1: \\ \" \' test string 2: \\ \" ' test string 3: \\ " \' test string 4: \\ " ' \` test string 5: \\ \" \' \`