Eric,
The solution was simple and elegant, but the lesson was invaluable!
Thank you!
D.

On Wednesday, 1 February 2017 18:24:59 UTC-5, Eric Shulman wrote:
>
> On Wednesday, February 1, 2017 at 1:14:56 PM UTC-8, David Szego wrote:
>>
>> This works to find a Tiddler created on a certain date of the month (in 
>> this case, the 1st):
>>
>> \define regExDateOfMonth() ^\d{6}01 />
>>
>> <$list filter="[regexp:created<regExDateOfMonth>]">
>> ...
>>
>> Either of these returns the correct string (^\d{6}01) but doesn't work:
>>
>> \define regExDateOfMonth() ^\d{6}<<now 0DD>> />
>>
>> <$list filter="[regexp:created<regExDateOfMonth>]">
>> ...
>>
>> \define dateOfMonth() <<now 0DD>>
>> \define regExDateOfMonth() ^\d{6}<<dateOfMonth>> />
>>
>> <$list filter="[regexp:created<regExDateOfMonth>]">
>> ...
>>
>> So, how do I find <<now 0DD>> at the 7th character of a field, in a 
>> regexp filter?
>>
>> Thanks! =-)
>>
>> David.
>>
>
> Keep in mind that macros are not "functions"... they don't "evaluate and 
> return" the result... rather, macro processing only does 3 things:
>   A) replace instances of $param$ using values passed to the macro as 
> arguments
>   B) replace instances of $(varname)$ using values defined outside the 
> macro as variables
>   C) return the resulting content for possible further processing in the 
> calling context
>
> It is up to that calling context to determine if the macro result should 
> be parsed further.
>
> Thus, when you wrote:
> \define regExDateOfMonth() ^\d{6}<<now 0DD>>
> the result was actually the literal value, "^\d{6}<<now 0DD>>", which is 
> then *rendered* by the calling context, causing the <<now>> macro to be 
> processed, producing the *displayed* output of "^\d{6}01".
>
> However, when that same macro result is used within the filter syntax:
> ... filter="[regexp:created<regExDateOfMonth>]" ...
> the returned macro value is NOT rendered, but simply used as a parameter 
> value for the regexp filter operator.  Thus, the <<now>> macro it contains 
> is left as a literal value.
>
> Try this instead:
>
> \define regExDateOfMonth() ^\d{6}$(dateOfMonth)$
>
> <$vars dateOfMonth=<<now 0DD>> >
> <$list filter="[regexp:created<regExDateOfMonth>]"\>
> </$vars>
>
> The main points:
>
> 1) First, $vars is used to store the *output* of the <<now>> macro (i.e., 
> "01") in a variable, "dateOfMonth".
>
> 2) In the regExDateOfMonth() macro, the dateOfMonth variable is referenced 
> using $(varname)$ syntax, which performs a *lexical substitution* of the 
> stored value before returning the desired result (i.e., the regexp pattern 
> using the actual month number in place of <<now 0DD>>).
>
> That should do it.  Let me know how it goes.
>
> enjoy,
>
> -e
> Eric Shulman
> TiddlyTools: Small Tools for Big Ideas!
> InsideTiddlyWiki: The Missing Manuals
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWikiDev" 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/tiddlywikidev.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywikidev/312757b8-7f95-47d8-beff-8671f153e96d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to