Try this:
In addition to your to your testStr and validStrList create another var evaluateStr and set its value to the expression that you want to evaluate, ie hardcode %testStr% == /%valStrList%/ into evaluateStr and check mark ‘Perform Variable Substitution’ when hardcoding the value. Now create your branch as follows:
Branch [Evaluate Label = True]
– Sequence [Label = %evaluateString%]
---- Do your stuff here
– Sequence [Label = $default]
I was very much convinced with Rohit’s solution, but its not working either…
I tried it. I dont think we can put regular expression with variable substitution…
Rohit can you please give it a quick go… It alwas goes in first sequence cause lable %evaluateString% means if evaluateString exist or not null then go in… and it does exist as "abx == /abc|xyz|efg/ " I also tried with value of evaluateString = “/abc|xyz|efg/”, still dont work…
I believe for Regular Expression we have to use evalute label equal to false but then we can not do variable substitution to have regualar expression dynamic…
My bad! Yes it goes to the first sequence because the var evaluateString exists in the pipeline. Hmmm I tried it many other ways but nothing seems to be working.
I think you’ll need to use other ways of determining whether your input var (testStr) is valid or not - you know, by tokenizing valStrings, looping over tokens and then branching… unless u find a way of doing this. If so please do share it with us.
I know the tokenizing way to doing it… I am already doing it at some other place but I believe it will be bit expesive than regular expression… But doesnt look like there is any other way…
Thanks for your inputs guys… Atleast its clear now…
Perhaps I’m not understanding the problem correctly, but I think you can do this using PSUtilities, as long as you’re running at least JVM 1.4. Before you do your BRANCH, call PSUtilities.regex:matches and map testStr to ‘input’ and validStrList to ‘regex’. Then BRANCH on the value of ‘match’ (true or false) to decide which sequence to take. HTH,
Variable substitution is not supported for regular expression in branch step. i had to wrote a small java service using java.util.regex.* for building my own rule engine.