RegEx-Wizards wanted

I want to extract Texts from Macros in a Tiddler with a regEx filter. The text looks like

Text...
...<<arbitraryMacro """The first text I want""" "multiple" "other" "SameID" >>
...text ..
.<<arbitraryMacro """A text I don't want""" "multiple" "other" "otherID" >>
...text ...
<<anotherarbitraryMacro """the other text I want""" "multiple" "other" "SameID">>...text...

Thus I would add an extractID variable to the macros and want the text in triple" in the macros with the same extractID

This may get more complicated if your """target text""" itself can contain <<, but here’s a quick attempt to get you started:

\function extract.id(id) [split[<<]search:title:regexp<id>] :map[split["""]nth[2]]

\define testing()
Text...
...<<arbitraryMacro """The first text I want""" "multiple" "other" "SameID" >>
...text ..
.<<arbitraryMacro """A text I don't want""" "multiple" "other" "otherID" >>
...text ...
<<anotherarbitraryMacro """the other text I want""" "multiple" "other" "SameID">>...text...
\end

{{{ [<testing>extract.id[SameID]] }}}

\function extract.id(id) is the functional bit here. I stuck your sample text in a macro for ease of testing, but you could also use [{Transcluded Tiddler}extract.id[SameID]] or [{!!field-name}extract.id[SameID]].

1 Like

Wow, this is elegant but I have no clue how it works…

Great solution, @etardiff Could I add numbers and linebreaks to it to get:

1. 
The first text I want
2. 
the other text I want