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

lloyd@REDACTED lloyd@REDACTED
Sun Dec 25 04:10:29 CET 2016


Hi Eric,

Swab looks very cool. But I'll have to wait until I've recovered from my New Year's hangover to dig in sufficiently to understand it.

Up for questions if they occur?

Thanks,

Lloyd 

-----Original Message-----
From: "Éric Pailleau" <eric.pailleau@REDACTED>
Sent: Saturday, December 24, 2016 6:33pm
To: "Erlang Questions" <erlang-questions@REDACTED>, "Lloyd R. Prentice" <lloyd@REDACTED>
Subject: Re: [erlang-questions] How can I break this string into a list of strings?

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





More information about the erlang-questions mailing list