Forum Discussion
Recursive Data Group Match
Hi,
I'm trying to perform a recursive binding of variables based off information in a large source string of values and a Data Group.
Here is the pseudo-logic of what I'm trying to perform...
DataGroup String "A" = Value "1" String "B" = Value "2" String "C" = Value "3"
Source_String : "A | C | Z | F | G | H | T | B"
I would like to recursively search $Source_String and bind the corresponding Data Group value for each match to a new variable. In the above example the desired variable output would be...
$Desired_Variable = "1 3 2"
Any ideas?
1 Reply
Hi Shopkeeper56,
you may try the iRule snippet below...
Datagroup:
ltm data-group internal DG_RESOLVE_CHARS { records { A { data 1 } B { data 2 } C { data 3 } } type string } `
iRule Snippet:
set input "A | C | Z | F | G | H | T | B" set output "" foreach char [split $input "|"] { if { [set dg_value [class match -value [string trim $char] equals DG_RESOLVE_CHARS]] ne "" } then { lappend output $dg_value } } log local0.debug "Output: \"$output\""
Logfile:
Sep 20 17:15:27 f5-02 debug tmm[11263]: Rule /Common/Debug : Output: "1 3 2"
Cheers, Kai
Recent Discussions
Related Content
* 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