unescape lua string (opposite of %q)
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: unescape lua string (opposite of %q)
- From: Graham Wakefield <wakefield@...>
- Date: Fri, 4 Jun 2010 22:02:22 -0700
Hmm, I must be slow. I can't figure out how to convert a string with represented control characters into a string with actual control characters.
E.g.:
local input = [[ line 1\nline2 ]]
Into a string which will print like this:
line1
line2
For individual characters, this works:
str:gsub("\\n", '\n')
But how can it be generic for all control characters?
str:gsub("\\(.)", '\%1') -- doesn't work