Pages: 1
RSS
Problems with subpatterns in regex
 
I'm trying to do what should be a simple job, but The Bat macro processing doesn't seem to be working as I'd expect. It's probably my understanding of the rather convoluted syntax of the macro language.

I've set up a regex to extract some text from the To: list. This includes a pair of brackets to produce a subpattern, But although the match succeeds, the subpattern is always null.

The macro code is:
Code
%SETPATTREGEXP="(?i)\s*([^,]*@xxxx\.com[^,]*)[,$]?"%-
Match is :%REGEXPMATCH="%OTOLIST": end of match%-
%_Patt='%SUBPATT="1"'%-
Subpattern is :%_Patt:
The output is :
Code
Match is :XXXX XXXX  <XXXX@xxxx.com>: end of match
Subpattern is ::
Even if I put '0' instead of  '1' for the SUBPATT argument I still get nothing, so I can only assume that either I'm using the wrong syntax for the call to %SUBPATT or the sub patterns aren't being set. I've tested this on a regex tester and the subpattern is picked up OK.

Anyone got any ideas how to mend this?

Thanks in advance

Peter
Peter
 
Regular Expressions are like Chinese to me, but shouldn't you use %SUBPATT(1) instead of %SUBPATT="1" ?

I'm only suggesting this because that's how I see it used in some other topics on this subject: (1) (2). Those two may be worth a look even if my suggestion doesn't make any sense - they contain some sample scripts similar in function to what you are trying to do.
I volunteer as a moderator to help keep the forum tidy. I do not work for Ritlabs SRL.
 
Thanks Daniel. It's interesting that the examples use both %SUBPATT="1" and %SUBPATT(1) syntax. As far as I can see, only the former is legal, and trying out the latter doesn't work. The examples are all fairly old, and I suspect that the macro language syntax has changed since 2011.

So I still don't have a solution. :cry:  
Peter
Pages: 1