# 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:** 1\
**Showing post:** 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.

---

_[View the full topic](https://community.dynatrace.com/t/matching-host-names-with-regex/30795)._
