Over in another thread 
<https://groups.google.com/forum/#!topic/tiddlywiki/4hE3-KUOqkY> I finally 
got to understand filters better. And, thanks to Mark S., achieved what I 
needed to do.

HOWEVER.

I feel slightly diminished. I am crap with computers. But one thing I know 
well is Regular Expressions. I was surprised at the very complex loops that 
i had to go through to CHANGE stuff in the way I needed to in that thread. 

Let me give an example ...

<$set name=test filter="
[list[!!text]prefix[#]]
[list[!!text]prefix[#]removesuffix['s]] +[!suffix['s]]
[list[!!text]prefix[#]removesuffix[.]] +[!suffix[.]]
[list[!!text]prefix[#]removesuffix[...]] +[!suffix[...]]
[list[!!text]prefix[#]removesuffix[,]] +[!suffix[,]]
[list[!!text]prefix[#]removesuffix[;]] +[!suffix[;]]
[list[!!text]prefix[#]removesuffix[:]] +[!suffix[:]]
[list[!!text]prefix[#]removesuffix[!]] +[!suffix[!]]
[list[!!text]prefix[#]removesuffix[?]] +[!suffix[?]]
[list[!!text]prefix[#]removesuffix[--]] +[!suffix[--]]
[list[!!text]prefix[...#]removeprefix[...]] +[!prefix[...]]
[list[!!text]prefix[--#]removeprefix[--]] +[!prefix[--]]
">

Here is sample data this deals with ...

left alone - #buddha #buddha #buddha 
remove apostrophised ending - #BuddHA's 
remove fullstop - #buddha. 
remove comma - #buddha, 
remove semicolon - #buddha; 
remove colon - #buddha: 
remove exclamation mark - #buddha! 
remove question mark - #buddha? 
remove 2 trailing dashes - #buddha-- 
remove 3 trailing stops - #BUDDHA... 
remove 2 leading dashes - --#Buddha 
remove 3 leading stops - ...#Buddha 
left alone - #notBuddha 
#BuddhaDANGER" (NOT YET DEALT WITH)
left alone #karma


In JavaScript Regular Expressions ALL these cases, and more---discarding 
the cruft of punctuation that all that code in the first box has to deal 
with---would be matched by simply: *"#w+\b"*. Nothing more would be needed.

If you could just transfer the match you would not have any of that 
prefix/suffix malarky to cope with.

WHY is it SO difficult in TW to do that? 

It seems nuts.

I am aware there is a regexp operator, but can it RETURN its exact match 
for processing, or is it what it looks like: a match with something IN a 
field it adds to a list to display but then the match itself is discarded?

All of this is as long way of saying two things ...

(1) Regular Expressions (BOTH match & replace) are natural TW allies

(2) I don't understand why we don't have a more friendly relationship with 
them.

Please ask if anything is unclear.

Best wishes
Josiah 

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/6339301e-ecdd-4615-b5c7-c510373ba662%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to