> <<forEachTiddler where
> 'tiddler.tags.sort().join("]]").contains(new RegExp("....\-..
> \-..","gm"))'
>
> Date tags with format "YYYY-0MM-0DD" should be found. As far as I
> understood the tag array is converted to a string after the join but I
> obviously do not understand how to apply the RegExp function to it ...

To test a text string against a regular expression, you can use
the .match() method of the string, passing the regexp as an argument:

var foo="some text";
if (foo.match(/some regexp/)) { ... }

If the pattern is found within the string, match() returns an *array*,
where match[0] is the complete matched text, and match[1..n] contain
matches for parenthesized sub-expressions (if any were used in the
regexp).  If no match is found, then match() returns a NULL (==false)
value.

Try this:

<<forEachTiddler where
'tiddler.tags.join(" ").match(/[0-9]{4}-[0-9]{2}-[0-9]{2}/)'

* I used a literal regexp (/.../) instead of creating a new RegExp
object within the forEachTiddler loop (more efficient).
* The regexp uses more specific matching (looks for numerics only)
* Except within the "[0-9]" regexp syntax, "-" is treated literally
and is not a special symbol.  It doesn't need backslash-quoting to be
matched.
* The tags don't need to be sorted, since you are matching across the
whole set of tags at once
* The tags are joined with " " rather than "]]".

enjoy,
-e
Eric Shulman
TiddlyTools / ELS Design Studios

----
TiddlyTools needs YOUR financial support...
Help ME to continue to help YOU...
make a generous donation today:
   http://www.TiddlyTools.com/#Donations

Professional TiddlyWiki Consulting Services...
Analysis, Design, and Custom Solutions:
   http://www.TiddlyTools.com/#Contact

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/tiddlywiki?hl=en.

Reply via email to