Grammar move to regex WIP

This commit is contained in:
barsdeveloper
2023-02-11 17:23:25 +01:00
parent 500965bcfc
commit d1ef250689
8 changed files with 221 additions and 167 deletions

View File

@@ -293,17 +293,21 @@ export default class Utility {
}
/** @param {String} value */
static escapeString(value, input = false) {
static escapeString(value) {
return value
.replaceAll('\\', '\\\\') // Escape \
.replaceAll('"', '\\"') // Escape "
.replaceAll("\n", "\\n") // Replace newline with \n
.replaceAll("\t", "\\t") // Replace tab with \t
}
/** @param {String} value */
static unescapeString(value, input = false) {
static unescapeString(value) {
return value
.replaceAll('\\"', '"')
.replaceAll("\\n", "\n")
.replaceAll("\\t", "\t") // Replace tab with \t
.replaceAll("\\n", "\n") // Replace newline with \n
.replaceAll('\\"', '"') // Escape "
.replaceAll('\\\\', '\\') // Escape \
}
/** @param {String} value */