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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -