Forum Discussion

emiliocb4_27077's avatar
emiliocb4_27077
Icon for Nimbostratus rankNimbostratus
May 11, 2011

scan problem

hi all,

 

 

follow is a part of my irule

 

 

set valore "*gtw1"

 

scan $valore %s%s primo secondo

 

log local0.debug " primo= $primo secondo= $secondo"

 

 

set valore1 "* gtw1"

 

scan $valore1 %s%s terzo quarto

 

log local0.debug " terzo= $terzo quarto= $quarto"

 

 

the first one doesn't work, the secondo one works.

 

 

how can i set as separator?

 

 

i tried to use ^ or or "^" or "" but none works

 

 

 

 

can u help me??

 

1 Reply

  • Hi Emilio,

     

     

    The problem is that everything but a space (or other whitespace) will be matched with %s:

     

     

    http://www.tcl.tk/man/tcl8.4/TclCmd/scan.htmM12

     

     

    So you'd need to be able to specify a character class that doesn't include the in order to use scan for the first string. If you just want to split the string on a specific character you can use getfield or split instead:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/getfield

     

    http://www.tcl.tk/man/tcl8.4/TclCmd/split.htm

     

     

    If neither of those options work, can you give more detail on what you're trying to parse? The more examples, the better.

     

     

    Aaron