Forum Discussion
jsgibbs1
Jul 20, 2015Nimbostratus
foreach command
I need to parse a data file for a custom string and assign the results to a variable. Each string has a similar prefix and is comma-separated.
Example:
custom_string_foo=[get this data w/out th...
Kevin_Stewart
Jul 20, 2015Employee
The string values don't matter at all. All you care about is that the strings are separated by commas, and that the data you want inside each string is inside square brackets.
set str {test1=[foo],test2=[bar],test3=[blah]}
foreach x [split $str ","] {
log local0. [findstr $x "\[" 1 "\]"]
}
returns:
foo
bar
blah
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