Scan - Making string manipulation efficient
Published Apr 24, 2008
Version 1.0Was this article helpful?
scan [HTTP::host] %s.%s.%s prefix host suffix
Since %s reads in all characters until the next whitespace, the whole [HTTP::host] string ends up in the variable 'prefix' and nothing is left to store in the succeeding variables. In addition, rather than setting these other variables to empty strings, they don't get defined at all so any succeeding reference to them generates a TCL error. The following would work
scan [HTTP::host] %\[^.\].%\[^.\].%s prefix host suffix