The splitregexp can be used to split on any delimiter!
It has two modifiers: m, and i
The question is how splitregexp can be used to split on first occurrence.
Example: There is a long long text and I want to split on first line! So filter shall returns only two non blank parts: the first line and the rest
<$list filter="[{myTiddler}splitregexp.........]>
</$list>
This is a very stupid but simple solution!
<$vars linebreak="""
""">
<$list filter="[{myTiddler}splitregexp[\n]!is[blank]first[]]
[{myTiddler}splitregexp[\n]rest[]join<linebreak>]">
. . . your code goes here . . .
</$list>
</$vars>
Note:
- its is simple (good)
- it computes the filter twice (bad)
I remembered your recent discussion on SetWidget which blowed my mind.
This is less simple than yours, but it doesn’t compute the filter twice (I think). Is having both a vars and a set widget worse?
<$vars lbr="""
""" firstsplit="\n{2,}">
<$set name="presplit" filter="[[myTiddler]get[text]splitregexp<firstsplit>!is[blank]]">
<$list filter="[enlist<presplit>first[]] [enlist<presplit>rest[]join<lbr>]" />
</$set>
</$vars>
What do you think?
@sull-vitsy - I think it does not work!
Consider a myTiddler like below
This is first line!
This is second
This is third!
and this is the last one.
You should get:
This is first line!
[[This is second This third!]] [[and this the last one. ]]
$set wrap each line with space into [[..]]