[erlang-questions] How to extract string between XML tags
Lloyd R. Prentice
lloyd@REDACTED
Sat Sep 29 17:11:19 CEST 2018
Thanks, Eric!
Best wishes,
Lloyd
Sent from my iPad
> On Sep 29, 2018, at 5:13 AM, PAILLEAU Eric <eric.pailleau@REDACTED> wrote:
>
> hello,
> sorry did not see this question before.
>
> A simple regexp is possible "<\/?[^>]{1,}>"
>
> re:replace("<th>title <b>bold</b></th>","<\/?[^>]{1,}>","", [global, {return, list}]).
> "title bold"
>
>
>
>> Le 25/09/2018 à 23:56, lloyd@REDACTED a écrit :
>> Hello,
>> By now I should know how to do this. But I've fumbled for more time than I have to find an elegant solution.
>> Can anyone show a better way?
>> Example string: "<th>Firstname</th>" % NOTE: could be any valid tag
>> My kludge:
>> extract_text(TaggedText) ->
>> Split = re:split(TaggedText, "<"),
>> Split2 = lists:nth(2, Split),
>> Split3 = binary_to_list(Split2),
>> Split4 = re:split(Split3, ">"),
>> Split5 = lists:nth(2, Split4),
>> binary_to_list(Split5).
>> Surely there's a better way.
>> Many thanks,
>> LRP
>> *********************************************
>> My books:
>> THE GOSPEL OF ASHES
>> http://thegospelofashes.com
>> Strength is not enough. Do they have the courage
>> and the cunning? Can they survive long enough to
>> save the lives of millions?
>> FREEIN' PANCHO
>> http://freeinpancho.com
>> A community of misfits help a troubled boy find his way
>> AYA TAKEO
>> http://ayatakeo.com
>> Star-crossed love, war and power in an alternative
>> universe
>> Available through Amazon or by request from your
>> favorite bookstore
>> **********************************************
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list