Parentheses in stream expression

I need to search for and replace a string that includes a “(”. Whenever I try this, I get a regex compilation error because the parentheses are not balanced. How do I make this work?

Here is my stream expression. I’m stuck and appreciate any help that I can get.

set stream_expression_cmd “STREAM::expression \”@/sap(@/test/sap(/@\“”

…

If you aren’t using variables in the stream expression you can wrap it in curly braces and avoid the need to escape meta-characters:

set stream_expression_cmd “STREAM::expression {@/sap(@/test/sap(/@}”

Aaron

Aaron, I tried that, but I still get the same regex compile error.

Are you using this iRule on multiple virtual servers where some may not have a stream profile enabled? If not, can you skip setting the stream expression in a variable and eval’ing it?

STREAM::expression {@/sap(@/test/sap(/@}

STREAM::enable

If you still get an error, can you reply with the full iRule, the LTM version you’re testing on and the actual text of the error?

Thanks, Aaron

That’s an odd one. Can you try replacing the ( with \x28? This worked in a simplified test on 10.2.3:

STREAM::expression {@/sap\x28@/test/sap(/@}
or:
set stream_expression_cmd {STREAM::expression {@/sap\x28@/test/sap(/@}}

Aaron

Still not working, but now getting the following error: Can’t compile regular expression - (/sap(?:slight_smile:

Here is the stream expression I am attempting to use:

set stream_expression_cmd “STREAM::expression {@/sap\x28@/test/sap(/@}”

LTM version is BIG-IP 10.2.0 Build 1755.1 Hotfix HF1. If you were able to get it to work in 10.2.3, maybe I need to look into upgrading to that version.

Thanks for your help Aaron. It is much appreciated. I was able to make this work on 10.2.3.