regexp to also accept empty or non-existing field

41 views
Skip to first unread message

Mat

unread,
Jul 2, 2020, 5:50:43 AM7/2/20
to TiddlyWiki
I want to ensure that a string does NOT contain another string located in a field:

{{{ mystring +[!regexp{!!foo}] }}}

Fair enough. But, obviously(!?), if that !!foo field doesn't exist or is empty then mystring should also pass the filter. But !regexp doesn't allow this. (I reason "if mystring does not contain 'emptystring' nor contains 'NIL' then it should pass")

How can I make a single filter that behaves as described?

Thank you!

<:-)

Saq Imtiaz

unread,
Jul 2, 2020, 7:11:36 AM7/2/20
to TiddlyWiki
You could try something like this (untested):

mystring +[!regexp{!!foo}] [{!!foo}!is[blank]then[]else[mystring]]

Eric Shulman

unread,
Jul 2, 2020, 3:54:26 PM7/2/20
to TiddlyWiki
On Thursday, July 2, 2020 at 4:11:36 AM UTC-7, Saq Imtiaz wrote:
You could try something like this (untested):
mystring +[!regexp{!!foo}] [{!!foo}!is[blank]then[]else[mystring]]

Slightly simplified and tested on tiddlywiki.com:
{{{ mystring +[!regexp{!!foo}] [{!!foo}is[blank]then[mystring]] }}}

-e

Mat

unread,
Jul 2, 2020, 5:20:22 PM7/2/20
to TiddlyWiki
Thank you both, Saq and Eric. My actual case is much more intricate so I've tried your solutions but they don't work there, unfortunately. I am, no surprise perhaps, working on EditorMagic and I'm about to make a public status update and had hoped to have this bit solved but it's just too complicated. So I'll post the update and if anyone is willing to take a look I'd be most happy.

Again thank you. The solution you did propose is still very good to know about. I had not properly looked at then+else before so this was valuable.

<:-)
Reply all
Reply to author
Forward
0 new messages