Forum Discussion
David_Homoney
Nimbostratus
Mar 06, 2008Regex in STREAM
So I am attempting to use regex with the stream profile in an iRule. I need this to catch all hrefs execpt for ones with a css file extension. I have tested this with regex buddy and it looks good, but the STREAM barfs. First, here is the regex.
href="[^"]*(?
Finally here is the error the STREAM profile spits out.
Mar 6 13:19:56 tmm tmm[1545]: 01220005:3: Can't compile regular expression - (href="[^"]*(?:?Mar 6 13:19:56 tmm tmm[1545]: 01220001:3: TCL error: Link_Scrub_v8 - couldn't compile regular expression pattern: quantifier operand invalidIllegal argument (line 1) invoked from within "STREAM::expression {@href="[^"]*(?
Any ideas? In the first log message it shows regex code that is different when what I have and you can see that in the second message. Very weird.
- hoolio
Cirrostratus
Unfortunately, TCL only supports lookaheads in regexes--not lookbehinds (negative or positive). I ran into this issue this week. I ended up having to collect the response content, use a more permissive regex with the regexp command and parse the results to only replace the strings that needed to be replaced. It would have been a lot easier with lookbehinds and a stream rule. Ugh... - David_Homoney
Nimbostratus
Thanks hoolio, I figured you would know. Unfortunately collecting the data in this case can't be done as it is well over 2mb and causes tmm to crash. Ugh is right. One step forward, two steps back. Thanks for the info. - hoolio
Cirrostratus
I can't really see a way of getting an exact match without lookbehinds. Maybe you can try Deb's collect/release suggestion in the codeshare (Click here). If you end up using a regex for matching links, you can use this to match more variations: (?i)href\s*=\s*(?:'|")[\w.:/]+(?:'|"). You could then add logic to update any matches which don't end in .css' or .css". - hoolio
Cirrostratus
Hi Homoney,
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects