How to extract all substrings with regex pattern matching

79 views
Skip to first unread message

Syed Murtza

unread,
Jul 9, 2016, 9:14:57 PM7/9/16
to elixir-lang-talk

I want to extract a list of all tags which are wrapped in {{ }} from following string and work on them i.e check db if they exist or not and than replace them as markdown link . i didnt find any String.scan function which returns substrings as a list. if you know how to do it than please let me know.


string


Lorem ipsum {{dolor}} sit {{amet}}, consectetur adipisicing {{elit}},


Thanks in advance for your effort and time :)

Syed Murtza

unread,
Jul 9, 2016, 9:19:40 PM7/9/16
to elixir-lang-talk

i can replace them with

String.replace(string, ~r/\{\{.+?\}\}/, "new substring")

but this doesnt help me because i can't work on substrings i.e check the db.

Theron Boerner

unread,
Jul 9, 2016, 9:46:33 PM7/9/16
to elixir-lang-talk
Regex.scan/3

--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/b33bf9d1-bff6-4d30-838e-2fd4db1ba64f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages