PDA

View Full Version : Regular expression in conditional build rule?


Rogier
12-14-2011, 11:44 AM
You can put conditional rules on build steps by selecting 'Build only if macro or expression...' and then there's options like 'is true', 'contains (x)', 'is not equal to (y)' etc.

It would be really great if you could add 'matches regexp (x)' and 'does not match regexp (y)' there!

Or is there some other way to pull this off?

kinook
12-14-2011, 12:07 PM
Create a project or global script function something like this:

Function MatchesRegEx(s, regex)
Set e = New RegExp
e.IgnoreCase = True
e.Global = True
e.Pattern = regex
MatchesRegEx = e.Test(s)
End Function

and call it from the build rule using a script expression (see the attached sample).

12/14/2011 10:07:24 AM: Building project step 1 - Test num...
12/14/2011 10:07:24 AM: Building project step 2 - Test str...
12/14/2011 10:07:24 AM: Step skipped

Rogier
12-14-2011, 06:32 PM
Awesome, thanks!