# Using a wildcard in DPL and matchesPattern()

**URL:** <https://community.dynatrace.com/t/using-a-wildcard-in-dpl-and-matchespattern/51776>\
**Category:** DQL\
**Tags:** dpl\
**Created:** [May 22, 2025, 8:44pm UTC](https://community.dynatrace.com/t/using-a-wildcard-in-dpl-and-matchespattern/51776 "2025-05-22T20:44:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Irvin\_naylor01](https://avatars.discourse-cdn.com/v4/letter/i/d6d6ee/32.png) [@Irvin\_naylor01](https://community.dynatrace.com/u/Irvin_naylor01)\
**Post date:** [May 22, 2025, 8:44pm UTC](https://community.dynatrace.com/t/using-a-wildcard-in-dpl-and-matchespattern/51776/1 "2025-05-22T20:44:45Z")

</div>

Hi all,

I’ve been diving into DPL and the matchesPattern() function to get around the lack of regex in filtering DQL results, so far all is well but I’m running into an issue.

Say for example, I’m filtering a set of hosts from a fetch dt.entity.host DQL query and I want to filter down specific hosts. I understand the way to create a DPL pattern that filters down some of those hosts, in the same vein as Regex.

The only roadblock I seem to not be able to get around is understanding how wildcards are implemented in DPL, if any. If I have multiple hosts names like this:

- “ABCDE-1234”
- “ABXYZ-3492”
- “ABLOL-1000.some.name”

My original thought was creating a matchesPattern() along the line of -

- matchesPattern(entity.name, “‘AB’ LD{3} ‘-’ DIGIT{4}”)

This would capture the first two host names listed above but to capture all three, I would of course use a wildcard to optionally include anything after the four digits of the name. However, unless I’m missing something while reading through the documentation for DPL, I don’t see a case for using a wildcard.&nbsp;Something that would allow me to match any cases where the pattern is explicitly matched \*and\* is contained in a larger string.

I may be going about this wrong but in a use case where I want to filter based off of a specific pattern (explicitly or included in a larger string), would DPL still be the correct way? Or should I be using something like contains()?

---

<div class="post-metadata">

**Author:** ![RafaelF](https://avatars.discourse-cdn.com/v4/letter/r/49beb7/32.png) [@RafaelF](https://community.dynatrace.com/u/RafaelF)\
**Post date:** [May 22, 2025, 9:42pm UTC](https://community.dynatrace.com/t/using-a-wildcard-in-dpl-and-matchespattern/51776/2 "2025-05-22T21:42:23Z")

</div>

Hello.I’m not sure if there is a correct way, but there are probably many ways to achieve what you are trying to do.For the DPL pattern including the “LD?” will match anything (optionaly), adding it at the end will capture all the 3 examples, you can also add it on the start if necessary.

```markup
filter matchesPattern(name, "LD? 'AB' LD{3} '-' DIGIT{4} LD?")

```

Other possible solutions I could think of:1. You can still use managementZones even though somewhat limited

```markup
fetch dt.entity.host
| filter in(managementZones, "my_mz")

```

```markup
timeseries avg(dt.host.cpu.idle), filter: in(dt.entity.host, classicEntitySelector("type(HOST),mzName(my_mz)"))

```

2. If you are using this for the new dashboards you could also create a hidden variable with a predefined list of hosts name/ids, set it to select all by default and use it to filter for the ones you want.Let me know if you need more help!  
Best Regards,Rafael Fernandes

---

<div class="post-metadata">

**Author:** ![Irvin\_naylor01](https://avatars.discourse-cdn.com/v4/letter/i/d6d6ee/32.png) [@Irvin\_naylor01](https://community.dynatrace.com/u/Irvin_naylor01)\
**Post date:** [May 23, 2025, 4:33pm UTC](https://community.dynatrace.com/t/using-a-wildcard-in-dpl-and-matchespattern/51776/3 "2025-05-23T16:33:55Z")

</div>

Thanks for the reply, Rafael

The first solution with LD? worked perfectly, don’t know how I missed that.&nbsp;The other solutions were also valuable- will keep those two in mind if this ever becomes a larger scope!

Thanks again!
