Forum Discussion

am_gli_287451's avatar
am_gli_287451
Icon for Nimbostratus rankNimbostratus
Dec 11, 2017

string trim generating strange results

Hi,

I have an issue with one of my string manipulations with variables:

set test [ACCESS::session data get session.http.last.response_cookie]
set test [lindex [split $test "|"] 0]
set test [string trim $test "Test="]

So, my cookie is built up like this:

  1. example: Test=ZTR(abc1234-1);ABC(qwe12314);|version=1;...
  2. example: Test=OEZZV(abc1234);ABC(qwe12314);|version=1...

In the first example, my $test ends up being correctly shown as "ZTR(abc1234-1);ABC(qwe12314);". In the second one, $test ends up being "ZZV(abc1234);ABC(qwe12314);".

So the "OE" is stripped away, although it shouldn't be. I've read about some odd results with trim when using numbers and I assume that this occurs because the OE (letter O, not number 0) represents some kind of value that is handled by the F5 differently.

But can anyone tell why and how to mitigate this? Is it possible to handle the variable as a string variable or similar, so that these changes of the values are not done?

Thanks in advance!

1 Reply

  • you can split header values with following code:

     

     split with both = and | characters and create an array
    array set cookie [split $test "=|"]
     get the value of cookie named Test
    set test2 $cookie(Test)