# Parse datagroup values as a list

**URL:** <https://community.f5.com/t/parse-datagroup-values-as-a-list/50733>\
**Category:** Technical Forums\
**Tags:** irules, devops, application-delivery\
**Created:** [February 4, 2014, 3:39am UTC](https://community.f5.com/t/parse-datagroup-values-as-a-list/50733 "2014-02-04T03:39:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![uni](https://avatars.discourse-cdn.com/v4/letter/u/9d8465/32.png) [@uni](https://community.f5.com/u/uni)\
**Post date:** [February 4, 2014, 3:39am UTC](https://community.f5.com/t/parse-datagroup-values-as-a-list/50733/1 "2014-02-04T03:39:29Z")

</div>

I have a datagroup which I am testing each element of:

```tcl
foreach item [class names my-dg] {
     if { [string match -nocase $item $teststring] } {

```

Unfortunately, if the datagroup elements have asterisks in them your config won’t load if mcpd does a forceload or you are updating the software (even though you can enter these entries through the GUI, or through tmsh if they are escaped with a “\”).

Anyway, I need to rewrite the rule, so I thought I’d just put all the names as values and have an arbitrary name such as a sequence number.

Can someone suggest a simple way to load the datagroup values as a list, so I can just loop through with a foreach, or some other efficient method of checking each value?

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [February 4, 2014, 10:25am UTC](https://community.f5.com/t/parse-datagroup-values-as-a-list/50733/2 "2014-02-04T10:25:11Z")

</div>

Use **class get**. It’ll produce a list of the keys and values, or rather a list of lists.

```tcl
when HTTP_REQUEST {
    set mylist [class get biglist]

    foreach x $mylist {
        log local0. "[lindex $x 0] : [lindex $x 1]"
    }
}

```
