Hi Peter,
On Tuesday, November 4, 2003 at 23:08 GMT +0100, an infinite number of
monkeys posting as Peter Fjelsten [PF] typed:
PF> Sorry for replying late but I've just stated a new job this Monday
PF> (usability engineer), so it's a bit hectic for me... :)
I know the feeling, but for different reasons. :)
PF> Er, it doesn't really.
PF> Something is halting the output as only the fixed text is output,
PF> i.e. the "NAVN=", etc.
This is when you try it in TB? Which type of template are you using?
PF> My problem is that when I load it into my RegExp tester it says
PF> "Couldn't compile regular expression pattern: quantifier operand
PF> invalid".
Well, your regexp tester might not use the same implementation for
regexps as TB.
PF> So it's hard for me to test here. If I remove "(?im-s)" it will
PF> compile some places.
Can't help you there. The expression works in TB's implementation.
Now I might have used the wrong macro in %RegexpBlindMatch, but I
don't think I did...
PF> It appears to match until Post code is listed at the fifth position.
Unless the tester is counting subpatterns incorrectly, the postal code
can't possibly be in the fifth position (assuming the regexp does what
I told it to do...). The subpattern counting is easy, just count how
many opening round brackets there are before the part you care about.
J>> VEDR0REND=%SetPattRegexp="(?ism)^(Date Ordered|Ordre
J>> modtaget):[^\n]*\n\s*(.*?)\s*\n(Products|Produkter):"%-
J>> %_________%RegexpBlindMatch="%Text"%-
J>> %_________%SubPatt("2")
PF> Maybe it's just me who don't really understand this, but here the tester
PF> doesn't complain about "(?im-s)"...
PF> What _is_ (?im-s)? What does it do?
Internal option setting. See the help file under:
|->Contents
|->Advanced Usage Topics
|-> Regular Expressions
|-> Regular Expression Syntax (Advanced)
|-> Internal Option Setting
J>> LEVERING=%RegexpText="(?im-s)^Sub-?total:.*?\n\s*?(.*)\s*?\n"
PF> If I remove (?im-s), the "^Sub-?total:.*?\n\s*?(.*)\s*?\n" matches. OK,
PF> now I get it: the RegExp tester sets the 'main match' as the one not in
PF> parantheses. TB can do it better and decide which one of the
PF> sub-patterns is the important one?
%RegexpText is a shortcut. If subpattern 1 is defined, that's what is
returned, otherwise subpattern 0 is returned.
J>> BETALINGSMETODE=For
J>> %_Shipping='%SetPattRegexp="(?im-s)shipping.*?(\d*([\.\,]d*)?)dkk\s*\n"%-
J>> %___________%RegexpMatch="%Text"'%-
J>> %-
J>> %If:'%SetPattRegexp="(?im-s)^Total:.*\n\s*?(Moms|DK\smoms/VAT)\n\n"'<>'':'%-
J>> FRAGTMOMSPLIGTIGT=%Calc="%_Shipping*0.8"dkk':'%-
J>> FRAGTMOMSFRI=%_Shipping'
PF> This seems to return "FRAGTMOMSFRI=" no matter what I test it on?
In a QT? Maybe there is some whitespace before after the Moms string.
Try adding \s*? between the "VAT)" and the "\n\n".
PF> Maybe I should test this by cutting it up and using it as QTs?
Definitely.
--
Thanks for writing,
Januk Aggarwal
________________________________________________________
http://www.silverstones.com/thebat/TBUDLInfo.html