Grepping for portions of text using regular expressions

Hi,

i have the following text where i want to grep the greenish highlighted portions out. As far i can see, there is no “easy-to-use” TW5 builtin-filter that returns the regexp-groups (the used regexp is (\\procedure.*?\\end) in the depicted example):

Basically i want to receive two entries in the filter including the \n's.

The example string on the picture is:

\procedure abc()
bla
\end

function func() jjj

\procedure kkk()
bli
\end

Thanks for any help or doc-pointers!

What’s the purpose of those filters? What do you try to achieve as an end result?

TW wikitext is not designed to be used that way. With functions regexps are doable but the code will get complex.

The purpose basically is just “find” things inside arbitrary text using regexp. There are many functions that somehow “cut” things using regexps but i was wondering if there is nothing that really greps for.

So your answer tells me at least that there are no builtin functions that i didn’t see :wink: . An according JS-filter like [find[regexp]] is easy to build, so i will go that way here.

What i’m trying to achieve? In the concrete example above 'm playing around a little bit with an idea of a type-system including component-based view-approaches within TW5.
But a general drawback with TW currently is: if one transcludes in complexer architectures, it will become problematic at certain points that you don’t know within which exact template-tiddler you are currently “operating” (when rendering contents in some tiddler-stage). So currentTiddler loses its value and there is no means of currentTemplate or something. So access to the currentTemplate's fields (which in some cases may contain needed information) is not possible anymore. Therefor i’m evaluating a func/proc/wid approach with namespacing that provides needed contextual configuration via variables that are then stored inside functions etc. within the text-field of the currentTemplate itself. That basically works for me, even if it still needs to be “polished” architecture-/understandability-wise.

But to make them available to the config-UI (for easy and nice usability) i need a way to read that config-information (that is provided within the mentioned func/proc/wid) and display it to the user. Currently i’m trying to sync fields forth and back from the text of the configuration-tiddler to some of its fields. By that i could then create simple and nice UI-elements in a classic TW5-fashion.

Anyways, wouldn’t a [find[regexp]] be generally handy for TW5?

Perhaps this custom operator (which I recommend renaming to something more distinct from regexp)?

Alternatively, you could use some combination of regexp and split or splitregexp to write a custom filter operator as a function. If you can provide some more examples of the sorts of input/output you’d like (ideally not as screenshots), I’m sure someone here can help.

It sounds like you’re looking for <<thisTiddler>>.

There are 2 functions already, that can filter using regexp.

There also is the splitregexp operator, but that one is not so useful for searching.

Hi @etardiff , thanks for the pointers! Wasn’t aware of <<thisTiddler>>. Maybe that helps for my issues, i will check that.

Best,
Mirko

Hi @pmario , thanks for the info, but both are not really able to (intentionally) grep stuff, except some awkward filter/regexp-“joga” :wink: => Oldie but Goldie -- the mythic regexps by Mark_S - #2 by pmario

Best,
Mirko

I future perhaps you could avoid or expand on jargon such as grep because that is just a command on Linux and users here are from all walks and OS’s in life :nerd_face:

I read your requirements and issues and I cant help but think you are going down a rabbit hole formed by the world in which you live. I feel it would be a good skill for you to develop to be able to expand your requirements to real world example’s that don’t depend on the specific technologies you are familiar with.

I am going to be bold and suggest native tiddlywiki can most likely provide the solutions you need but as long as you ask how to grep and regexp the answers will most likely only be in that specific area.