Split Operator, confused why doesn't work for me at all

i am new to Tiddlywiki

followed the doc instruction, but mine looks like this, below screenshot.
need help on what am i missing here!!!

Try your tests in the Filter tab of Advanced Search, or wrapped in triple curly braces. Filters on their own are not evaluated in wikitext unless used in a context that evaluates them.

1 Like

Try your filters in Advanced Search (Filter tab), or enclose them between triple curly braces like this:
{{{ [[Mississipi]split[i]] }}}

Fred

1 Like

thanks!!!..
i am trying to use those expression to get “files/documents/” out of
“files/documents/myfile.pdf”

but below give me syntax error…

{{{ [[files/documents/myfile.pdf]splitbefore[last[/]]] }}}

You’ve tried to nest a whole additional expression last[] inside the splitbefore operator. (Also, you were treating [/] as a value for the last filter operator, while it only takes numbers. See documentation).

What you want is

{{{ [[files/documents/myfile.pdf]split[/]butlast[1]join[/]] }}}

(I’ve specified butlast[1] to illustrate how filter operators like last[] and butlast[] use numbers, but you can take out the 1 and get the same result with butlast[] since it defaults to 1.)

A general rule of thumb about filter expressions is: you can only get two brackets deep, within the filter expression (this will include curly brackets { } and angle brackets < >, too). If you’re already inside the scope of an operator (such as [...splitbefore[PARAMETER] ...]) you can’t embed another operator in that PARAMETER location.

1 Like

now i have another problem , i actually store those relative path in canonical_uri field.

{{Screenshot 2025-02-21 101007.png!!_canonical_uri}}

but seems i can’t simple replace “files/documents/myfile.pdf” with {{Screenshot 2025-02-21 101007.png!!_canonical_uri}}

{{{ [[{{Screenshot 2025-02-21 101007.png!!_canonical_uri}}]split[/]butlast[1]join[/]] }}}

any solution, thanks again!

You are using double brackets inside a filter run.

See Those Pesky Brackets — ...and other wikitext punctuation

Create a tiddler named New Tiddler with a field named foo with value bar.

Reference it in another tiddler:

{{{ [[{{New Tiddler!!foo}}]] }}}

{{{ [{{New Tiddler!!foo}}] }}}

{{{ [{New Tiddler!!foo}] }}}

{{{ [[New Tiddler]get[foo]] }}}

this renders as:

{{New Tiddler!!foo}}
Filter error: Missing [ in filter expression
bar
bar

You can see that first and second versions do not work as expected.

Third version works as per Pesky Brackets above.

But I still find it less readable because it nests brackets.

For this reason you may want to consider using the get filter operator instead, as in fourth example.

1 Like

My comment about nesting only two brackets applies here as well:

gets four bracket-layers deep, rather than just 2. Modify like so:

{{{ [{Screenshot 2025-02-21 101007.png!!_canonical_uri}split[/]butlast[1]join[/]] }}}
1 Like

thanks for it . it works perfect!

There really should be a useful place to capture wisdom such as this. It took me far too long to understand this as a general principle, and even a year after I finally got it, it still once in a while trips me up. Someday I want to get back to my documentation ideas, but there are so many shiny things out there!