I'm playing with version that does replacement with regexp. Based on 
original regexp code with a couple of tweaks. Seems to work. Absolutely 
make backups, because sometimes one gets blind-sided by subtle 
discrepancies as I discovered with the  seemingly simple tolower filter.

After install, your hashtag2tag filter could look like 

[list[!!text]regexps[#\w+\b]tolower[]]

if you also installed the latest edition of tolower (in other thread,  
first version had a subtle bug).

I suppose the problem with this simple approach is that a regular 
expression could return many results (I didn't try the global options). 
Some people might expect all those hits to be returned. That might pose 
complications.

Thanks,
Mark


On Wednesday, August 23, 2017 at 11:19:35 AM UTC-7, @TiddlyTweeter wrote:
>
> 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 tiddlywiki+unsubscr...@googlegroups.com.
To post to this group, send email to tiddlywiki@googlegroups.com.
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/537e97b8-7f82-464c-a267-d86e69b86347%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: $__core_modules_filters_regexps.js.json
Description: application/json

Reply via email to