# Help with the RegEx for tagging rule

**URL:** <https://community.dynatrace.com/t/help-with-the-regex-for-tagging-rule/32264>\
**Category:** Open Q&A\
**Tags:** regex, tagging\
**Created:** [July 30, 2021, 7:59pm UTC](https://community.dynatrace.com/t/help-with-the-regex-for-tagging-rule/32264 "2021-07-30T19:59:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [July 30, 2021, 7:59pm UTC](https://community.dynatrace.com/t/help-with-the-regex-for-tagging-rule/32264/1 "2021-07-30T19:59:04Z")

</div>

Hi Folks,

I would need some help in defining a tagging rule that can match the set of hosts and assign tag to them.

The hostnames could be like below,

**host1, host2, host3, server1, server2, machine1, machine2**

and the expression I tried was

**host|server|machine** &nbsp;bot it matches only host1 host2 and host3.

Please help me to build RegEx that can match all listed hosts

Regards,

AK

---

<div class="post-metadata">

**Author:** ![ryan\_ott](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ryan_ott/32/15818_2.png) [@ryan\_ott](https://community.dynatrace.com/u/ryan_ott)\
**Post date:** [July 30, 2021, 9:55pm UTC](https://community.dynatrace.com/t/help-with-the-regex-for-tagging-rule/32264/2 "2021-07-30T21:55:17Z")

</div>

Hello,

Try placing the regex in parentheses like this: “(?\>host|server|machine)”  
Also, make sure you are selecting Host Name contains regex.

Please see the screenshots below for how I was able to mimic this functionality. Hope this helps!

 ![ryan_ott_0-1627682099157.png](https://global.discourse-cdn.com/dynatrace/original/3X/8/3/83a626db380698a9bd376e3da344517da5e1d37c.png)

 ![ryan_ott_1-1627682107386.png](https://global.discourse-cdn.com/dynatrace/original/3X/b/b/bb488746741d3e05b322d2c244828e1d3075c0da.png)

-Ryan

---

<div class="post-metadata">

**Author:** ![AK](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/ak/32/164_2.png) [@AK](https://community.dynatrace.com/u/AK)\
**Post date:** [July 31, 2021, 3:16pm UTC](https://community.dynatrace.com/t/help-with-the-regex-for-tagging-rule/32264/3 "2021-07-31T15:16:08Z")

</div>

Great it worked **Ryan**. Thanks for helping me out.
