# Matching Host Names with Regex

**URL:** <https://community.dynatrace.com/t/matching-host-names-with-regex/30795>\
**Category:** Open Q&A\
**Tags:** tagging\
**Created:** [March 15, 2021, 8:17pm UTC](https://community.dynatrace.com/t/matching-host-names-with-regex/30795 "2021-03-15T20:17:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [March 15, 2021, 8:17pm UTC](https://community.dynatrace.com/t/matching-host-names-with-regex/30795/1 "2021-03-15T20:17:45Z")

</div>

Hi community, I wrote the following Regex to match either hostname formats:

| (?:ocp-p[a-zA-Z]-a\d{0,2}|worker-\d{0,2}\.ocp4-re)\.cloud\.com |
| --- |

The hostname are dynamically created.

I’ve check the rule on [Regex 101](https://regex101.com/) and matches everything as expected, but when I go to Dynatrace and hit preview only matches example 1 and 4. What I’m doing wrong?

[worker-10.ocp4-re.cloud.com](http://worker-10.ocp4-re.cloud.com)  
[ocp-pe-a2.cloud.com](http://ocp-pe-a2.cloud.com)  
[ocp-pe-a42.cloud.com](http://ocp-pe-a42.cloud.com)  
[worker-0.ocp4-re.cloud.com](http://worker-0.ocp4-re.cloud.com)

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Babar\_Qayyum](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/babar_qayyum/32/13620_2.png) [@Babar\_Qayyum](https://community.dynatrace.com/u/Babar_Qayyum)\
**Post date:** [March 16, 2021, 6:16am UTC](https://community.dynatrace.com/t/matching-host-names-with-regex/30795/2 "2021-03-16T06:16:24Z")

</div>

Hello&nbsp;[@DanielS](https://community.dynatrace.com/user/35788)

Please try the following:

```markup
(?:.*cloud.com)

```

Regards,

Babar

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [March 19, 2021, 7:00pm UTC](https://community.dynatrace.com/t/matching-host-names-with-regex/30795/3 "2021-03-19T19:00:33Z")

</div>

I’d recommend using what&nbsp;[@Babar\_Qayyum](https://community.dynatrace.com/user/22017)&nbsp;supplied, if that still fails (which i dont expect) then maybe make 4 rules, one for each line item to ensure they are working correctly.

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [March 19, 2021, 8:24pm UTC](https://community.dynatrace.com/t/matching-host-names-with-regex/30795/4 "2021-03-19T20:24:06Z")

</div>

Thanks, finally instead of doing one rule, I made one for 1 and 4 and other one for the 2,3. It’s not what I wanted, but the field is limited to 80 chars, so If in a future I add more examples it would be easier to maintain.

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [March 19, 2021, 8:27pm UTC](https://community.dynatrace.com/t/matching-host-names-with-regex/30795/5 "2021-03-19T20:27:26Z")

</div>

great to hear, but yes I’ve run into issues too with character limits for regex, but still cut down on the overall rules. glad it worked

Maybe toss in a RFE for that limit to be raised.

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [March 19, 2021, 8:28pm UTC](https://community.dynatrace.com/t/matching-host-names-with-regex/30795/6 "2021-03-19T20:28:49Z")

</div>

Good Idea, I’ve done a request and wait if it accepted. Thanks for your answers.

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [March 19, 2021, 8:29pm UTC](https://community.dynatrace.com/t/matching-host-names-with-regex/30795/7 "2021-03-19T20:29:12Z")

</div>

thanks for your answer.

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [March 19, 2021, 8:29pm UTC](https://community.dynatrace.com/t/matching-host-names-with-regex/30795/8 "2021-03-19T20:29:45Z")

</div>

toss along the link and ill up vote it

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [March 19, 2021, 8:36pm UTC](https://community.dynatrace.com/t/matching-host-names-with-regex/30795/9 "2021-03-19T20:36:59Z")

</div>

[https://community.dynatrace.com/t5/Dynatrace-product-ideas/RFE-Raise-Regex-Field-Limit/idi-p/163183](https://community.dynatrace.com/post/163183)

Done
