Forum Discussion

BrianOhio's avatar
BrianOhio
Icon for Nimbostratus rankNimbostratus
Jan 17, 2014

STREAM::expression regular expression sporadic inconsistency...

Hi,

 

First just a little background. We have an iRule that needs to translate the URLS within web pages to hide some internal information in the URL from the outside world. For example, there are many URLs like this in the pages of our web apps: /f?p=1002:29:9635291638390:::other:stuff The STREAM processing in the iRule translates these into this: /ap/29?9635291638390:::other:stuff Ie, it translates the "/f?p=1002:29:" into "/ap/29?"

 

Now, at first the STREAM::expression regexp I used for this was: {@/?f\?p=\d+:\w+:\w+@@} But in some, seemingly non-deterministic, intermittent cases, we started seeing it truncate the long number (its a session key) after the "29:". For example instead of the above, we would sometimes see: /ap/29?963:::other:stuff But if you reloaded the same page, another URL might have the problem and the one that had it the last time would be fine.

 

It is my understanding that the plus sign in a regexp (\w+) is supposed to always be "greedy" and match all of the possible characters it can, but this behavior is making me think that there is a regular expression bug in the TCL that iRules use that causes it to sometimes not be greedy.

 

By the way, removing that last "\w+" from the regular expression seems to have solved the problem, but it is still disturbing as to why the original expression was having these intermittent incorrect matches.

 

Thanks for any insight anyone might have on this...

 

-- Brian