# Parentheses in stream expression

**URL:** <https://community.f5.com/t/parentheses-in-stream-expression/34582>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [March 14, 2012, 5:29pm UTC](https://community.f5.com/t/parentheses-in-stream-expression/34582 "2012-03-14T17:29:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_45699](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@John\_45699](https://community.f5.com/u/John_45699)\
**Post date:** [March 14, 2012, 5:29pm UTC](https://community.f5.com/t/parentheses-in-stream-expression/34582/1 "2012-03-14T17:29:17Z")

</div>

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(/@\“”

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [March 14, 2012, 5:34pm UTC](https://community.f5.com/t/parentheses-in-stream-expression/34582/2 "2012-03-14T17:34:37Z")

</div>

…

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [March 14, 2012, 5:34pm UTC](https://community.f5.com/t/parentheses-in-stream-expression/34582/3 "2012-03-14T17:34:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![John\_45699](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@John\_45699](https://community.f5.com/u/John_45699)\
**Post date:** [March 14, 2012, 5:52pm UTC](https://community.f5.com/t/parentheses-in-stream-expression/34582/4 "2012-03-14T17:52:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [March 14, 2012, 6:09pm UTC](https://community.f5.com/t/parentheses-in-stream-expression/34582/5 "2012-03-14T18:09:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [March 14, 2012, 8:03pm UTC](https://community.f5.com/t/parentheses-in-stream-expression/34582/6 "2012-03-14T20:03:59Z")

</div>

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

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

```

Aaron

---

<div class="post-metadata">

**Author:** ![John\_45699](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@John\_45699](https://community.f5.com/u/John_45699)\
**Post date:** [March 15, 2012, 3:16pm UTC](https://community.f5.com/t/parentheses-in-stream-expression/34582/7 "2012-03-15T15:16:40Z")

</div>

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

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.

---

<div class="post-metadata">

**Author:** ![John\_45699](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@John\_45699](https://community.f5.com/u/John_45699)\
**Post date:** [March 15, 2012, 7:20pm UTC](https://community.f5.com/t/parentheses-in-stream-expression/34582/8 "2012-03-15T19:20:00Z")

</div>

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