[TW5] search and regexp

157 views
Skip to first unread message

John

unread,
Aug 14, 2015, 1:30:22 PM8/14/15
to tiddl...@googlegroups.com
A regular search for "{{}}" in documentation does not return any results.
A user posted it was for "Transclusion"
Being new to TW5 it was very difficult searching the documentation what "{{}}" meant.

After knowing it was for "Transclusion", figured a filter search["{{}}"] returns a tiddler about "Transclusion"

Curious to know how the same can be done using regexp[] 
Would be helpful for searching code patterns in contents of tiddlers.

Any help?





PMario

unread,
Aug 14, 2015, 3:18:08 PM8/14/15
to TiddlyWiki
Hi John,

TW search does an exact search. So if you search for "{{}}" you'll probably get no hits at all. If you search for "trans" or "{{" or "}}" you'll get a lot of hits.

I did send you a link, that opens 2 tiddlers. Those 2 tiddlers contain 8 more links to the exact topics.
If you type "transclude" into the search box, you get about 30+ hits.

regexp search is at the "advanced search" box. Open the filter tab.

see: http://tiddlywiki.com/#regexp%20Operator:%5b%5bregexp%20Operator%5d%5d%20%5b%5bregexp%20Operator%20%28Examples%29%5d%5d%20%24%3A%2FAdvancedSearch
The best source for javascript regexp imo is: http://www.regular-expressions.info/javascript.html

have fun!
-mario

John

unread,
Aug 15, 2015, 1:20:12 AM8/15/15
to tiddl...@googlegroups.com
Still does not explain why regex pattern "{{[a-zA-Z0-9]*}}" does not yield the same results.

But thanks anyway.

PMario

unread,
Aug 15, 2015, 12:14:08 PM8/15/15
to tiddl...@googlegroups.com
On Saturday, August 15, 2015 at 7:20:12 AM UTC+2, John wrote:
Still does not explain why regex pattern "{{[a-zA-Z0-9]*}}" does not yield the same results.

Because regexps are difficult. 

You don't allow spaces. So your regexp breaks if it hits the first space. ... and TW pattern matching also uses regexps. So there are some limitations. eg: tiddler titles that contain wikitext closing delimiters as: ] ]] } }} and so on need to be escaped or even better avoided by the user.

Your regexp means:

// {{[a-zA-Z0-9]*}}
//
// Options: case insensitive; ^ and $ match at line breaks
//
// Match the characters “{{” literally «{{»
// Match a single character present in the list below «[a-zA-Z0-9]*»
//    Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
//    A character in the range between “a” and “z” «a-z»
//    A character in the range between “A” and “Z” «A-Z»
//    A character in the range between “0” and “9” «0-9»
// Match the characters “}}” literally «}}»

Please have a look at: http://tiddlywiki.com/#regexp%20Operator%20%28Examples%29

There you can see, that your regexp has no chance to work, due to the above mentioned TW design decisions. TW uses brackets [] to detect wikitext.

The advanced search field pattern, you want would need to look like this: [regexp[{{[a-zA-Z0-9 ]*}}]]    <- I did add a space.

.... BUT ... see the last example.

Since TW wikitext detection also uses brackets [] and curly bracktes {} as delimiters, the last example doesn't work either out of the box.

But luckily js regexp knows unicode. where { is \u007b  and } is \u007d

So you may have more luck with:
 
<$set name="digit-pattern" value="""\u007b\u007b[a-zA-Z0-9 ]*\u007d\u007d""">
<<list-links "[regexp:text<digit-pattern>]">>
</$set>

OR

Use "trans" or "{{" or "}}" in the standard search field.

have fun!
mario


Reply all
Reply to author
Forward
0 new messages