Hello Ottar,

Historians believe that Thu, 19 Apr 2001 at 00:31 GMT +0200 was when,
Ottar Grimstad [OG] typed the following:

<snip>
OG> I have struggled with the macro semantics of this line. Have I
OG> understood this correctly?

OG> You put all these statments on one line so that the text shall be
OG> output on the top line of the letter. It is possible to split this
OG> into 4 macro statments (the second statement contains 5 macro
OG> statements inside itself):

OG> %SETPATTREGEXP="(?i)(?(?=.*?\<list\>.*?;;.*;;.*).*;;(.*);;.*|.*;;.*;;(.*))"
OG> 
%REGEXPBLINDMATCH="%TOLIST%CCLIST%BCCLIST;;%QINCLUDE=""GROUP"";;%QINCLUDE=""INDIV"""
OG> %SUBPATT="1"
OG> %SUBPATT="2"

OG> %REGEXPBLINDMATCH collects 3 strings:
OG> %TOLIST%CCLIST%BCCLIST,
OG> %QINCLUDE=""GROUP"",
OG> %QINCLUDE=""INDIV"""

Right.

OG> These 3 strings are matched by %SETPATTREGEXP
OG> Inside the conditional paranthese, the first string is checked for the
OG> apperance of <list>, the other two strings can be whatever they want.

Right.

OG> Two substrings are set.
OG> If the condition is met, then the last substring is made empty. The
OG> first substring takes all the three strings, eject the first and last
OG> and only keep the middle one marked with paranthese (.*), which
OG> happens to be the Quicktemplate with handle Group.
OG> If the condition is not met, the first substring is made empty. The
OG> last substring collects all three strings but ejects the first and
OG> second and only keep the third marked with paranthese (.*) which
OG> happens to be the Quicktemplate with handle Indiv.

Looks about right.

OG> %SUBPATT="1"%SUBPATT="2" prints both substrings, but since one of them
OG> is empty, we only see the %SUBPATT that actually contains text.

Right.

OG> But I still do not quite get these .* and (.*). In the help file
OG> it is said that * matches zero or more instances of the atom.
OG> How is it that .* returns nothing while (.*) returns the
OG> whole string?

They both match any number of any character, but the parentheses
highlight one particular section.  So the first set of parentheses
says, "This is important, so keep this to the side: in Subpattern 1".
The second set of parentheses says, the same thing, but now in
Subpattern 2.  The rest of the regexp is still matched, but it isn't
considered special, therefore it is kept in Subpattern 0.

Try making a test template with:
<begin test template>
%SETPATTREGEXP="(?i)(?(?=.*?\<list\>.*?;;.*;;.*).*;;(.*);;.*|.*;;.*;;(.*))"%REGEXPBLINDMATCH="%TOLIST%CCLIST%BCCLIST;;%QINCLUDE=""GROUP"";;%QINCLUDE=""INDIV"""
Subpatt 0: <%SUBPATT="0">
Subpatt 1: <%SUBPATT="1">
Subpatt 2: <%SUBPATT="2">
Subpatt 3: <%SUBPATT="3">
<end test template>

Run that and see what happens.  Hopefully it will help clear things up
a bit.


-- 
Thanks for writing,
 Januk Aggarwal

Using The Bat! 1.51 under Windows 98 4.10 Build 2222  A

-- 
______________________________________________________
Archives   : <http://tbtech.thebat.dutaint.com>
Moderators : <mailto:[EMAIL PROTECTED]>
Unsubscribe: <mailto:[EMAIL PROTECTED]>

You are subscribed as : [email protected]


Reply via email to