Regular expressions

Hi everybody,

Can we create a regular expression pattern dynamically using a pipeline variable and use it in branch statement.

thanks and regards

I am not very sure what you want but try using Branch statement with Evaluate Labels set to True.

Give an example of your problem, it will be easier to respond

Thanx for the prompt response Sreedhar.

The following is the requirement.

I get a CODE like “i12345” as input variable.
This code has to be compared to see if the first letter matches a certain predefined character. This character is stored in db and has to be retrieved at run time.

To check the condition, I thought of using a regular expression whose pattern can be generated from the value retrieved from db ( say code)

My regular expression should look something like this


But this option was not successfull and I ended up using services under pub.String folder to achieve the requirement.

I would just like to know, if the regular expression patterns can be created dynamically using pipeline variables.

thanks and best regards


Did u find the solution to this?

You could branch on “code” set the evaluate labels to false and add sequence steps or map steps to match the first characters.

BRANCH on “/code”(Evaluate Labels = false)

--    /[/^i/]/MAP(Starts with i)

--     Default Map - Do nothing


Hi Krishna,

I had wrongly phrased the previous reply.

The variable will have the value i12345
The CODE will have a single character like i (this value is dynamic and retrieved from db)

We need to write a regular expression like:


I tried this option, but it doesnt seem to work.

In this case did you set Evaluate Labels = true?? because you are trying regular expression and variable substituion syntax at the same time.


You can always evaluate the regular expression first, using PSUtilities.regex:matches or a similar java service, and branch on the outcome of that test.



I tried out your solution and it worked. Thanks a lot.


I am working on your solution and will let you know the result of the same. Thanks for the support extended.