[erlang-questions] How can I break this string into a list of strings?

Kenneth Lakin <>
Sat Dec 24 23:42:58 CET 2016


On 12/24/2016 01:34 PM,  wrote:
> I don't want those pesky escaped quotes at the end of the heads. I want the real deal. 

Does it help you to know that those double-quotes aren't _actually_
escaped and that the backslashes are added by the pretty-print code?
Continuing on with your example:

2> B=re:replace(Copy, [$>,$\n], [$>,$",$,,$"], [global, {return, list}]).
%re:replace output elided
3> lists:nth(16, B).
34
4> lists:nth(15, B).
62

ASCII 34 is '"'. ASCII 62 is '>'. There's no "\" in the output, which
would be ASCII 92:

5> lists:foldl(fun(92, Acc) -> Acc ++ [92]; (_, Acc) -> Acc end, [], B).
[]

The pretty-printer is a nice feature (AFAICT, anything the
pretty-printer prints is valid Erlang), but I suspect that being
startled by its escaping is a rite of passage.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161224/f87964b0/attachment.bin>


More information about the erlang-questions mailing list