[erlang-questions] How can I break this string into a list of strings?
Constantine Povietkin
povetkin.k@REDACTED
Sat Dec 24 22:43:20 CET 2016
Hi,
Just convert it to binary and use binary:split.
В Суб, 24/12/2016 в 16:34 -0500, lloyd@REDACTED пишет:
> Hello,
>
> A naive question.
>
> But every time I look into the re module my heart starts pounding. I
> spend uncountable time figuring out what I need to do. But this time
> I failed.
>
> Suppose I have the following string:
>
> "<h1>Hello!</h1>\n <h2>How are you?</h2>\n <p>Some text\n
> and more text.</p>"
>
> I would like to break it into a list:
>
> ["<h1>Hello!</h1>", "<h2>How are you?</h2>", "<p>Some text\n and
> more text.</p>"]
>
> string:token(MyString, "$\n") doesn't work because it would break the
> paragraph.
>
> So I try:
>
> re:replace(Copy, [$>,$\n], [$>,$",$,,$"], [global, {return,
> list}]).
>
> But I get:
>
> "<h1>Hello!</h1>\",\" <h2>How are you?</h2>\",\" <p>This
> is....
>
> I don't want those pesky escaped quotes at the end of the heads. I
> want the real deal.
>
> But how can I make it happen?
>
> Thanks and holiday cheer to all,
>
> LRP
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list