[erlang-questions] How can I break this string into a list of strings?
Éric Pailleau
eric.pailleau@REDACTED
Sun Dec 25 00:33:13 CET 2016
Hi,
If re module make your heart pounding,
you may give a try to https://github.com/crownedgrouse/swab
and create powerful macros to apply on your buffers.
"Envoyé depuis mon mobile " Eric
---- lloyd@REDACTED a écrit ----
>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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20161225/6cda028c/attachment.htm>
More information about the erlang-questions
mailing list