java - How to de-escape string in scala? -
i found many posts escaping string no de-escaping one.
using scala play, controller accept json request. extract string via:
val text: play.api.libs.json.jsvalue = request.body.\("source")
if print text.tostring
e.g.
"hello\tworld\nmy name \"abc\""
how can transform escaped text normal one? result should like
hello world name "abc"
up point, i've tried approach follows:
replaceall("""\\t""", "\t")
however, creating possible escaping rules may complicated. question is: how easily? possibly using standard library. java solutions possible.
there interpolations allow transform strings formatted and/or escaped sequences. these interpolations s"..."
or f"..."
handled in stringcontext.
it offers reverse function:
val es = """hello\tworld\nmy name \"abc\"""" val un = stringcontext treatescapes es
Comments
Post a Comment