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
Something like this:
set example {custom_string_foo=[get this data w/out the brackets], custom_string_bar=[get this data too],custom_string_again=[keep getting data until no more instances of custom_string]}
foreach x [split $example ","] {
log local0. [findstr $x "\[" 1 "\]"]
}
The split command breaks the larger string into list items, and then the foreach loops through that list and extracts the string between the brackets using the findstr command.
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