# Service Naming using Regex

**URL:** <https://community.dynatrace.com/t/service-naming-using-regex/31212>\
**Category:** Open Q&A\
**Tags:** regex, services-classic, naming-rules\
**Created:** [April 21, 2021, 8:23pm UTC](https://community.dynatrace.com/t/service-naming-using-regex/31212 "2021-04-21T20:23:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bill\_scheuernst](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/bill_scheuernst/32/2211_2.png) [@bill\_scheuernst](https://community.dynatrace.com/u/bill_scheuernst)\
**Post date:** [April 21, 2021, 8:23pm UTC](https://community.dynatrace.com/t/service-naming-using-regex/31212/1 "2021-04-21T20:23:43Z")

</div>

I am stumped!&nbsp; I am trying to setup a service naming rule using the Detected Service Name.&nbsp; In this case, I would only like the bolded text - (/ **mothership** ).&nbsp; How do I extract only this word using Regex?

I have tried -

- ^[a-zA-Z0-9]\*+
- \/(?\>.+)

For these attempts, I get close, but still have varying results.&nbsp; I want to remove the slash and the () and only have the word.

What I really want is this…

Detected Service Name - “Default Web Site:80 (/mothership)” \>\>\>\>\> “mothership”

{Service:DetectedName]

Web Request Service; .NET

Detected service name contains regex

---

<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:** [June 17, 2021, 9:23pm UTC](https://community.dynatrace.com/t/service-naming-using-regex/31212/2 "2021-06-17T21:23:16Z")

</div>

While this is very primitive, you could try&nbsp;(…).$ but then again that would be static on the number of characters

---

<div class="post-metadata">

**Author:** ![dave\_mauney](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dave_mauney/32/27784_2.png) [@dave\_mauney](https://community.dynatrace.com/u/dave_mauney)\
**Post date:** [June 30, 2021, 4:31pm UTC](https://community.dynatrace.com/t/service-naming-using-regex/31212/3 "2021-06-30T16:31:11Z")

</div>

Have you considered just skipping the regex entirely and using the&nbsp;{Service:WebContextRoot} placeholder?

 ![dave_mauney_0-1625070640730.png](https://global.discourse-cdn.com/dynatrace/original/3X/e/7/e7cd4f32f12afa43fa7e3778b0b22876b9a2f112.png)

You could then remove the slash with regex if really needed…

---

<div class="post-metadata">

**Author:** ![bill\_scheuernst](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/bill_scheuernst/32/2211_2.png) [@bill\_scheuernst](https://community.dynatrace.com/u/bill_scheuernst)\
**Post date:** [July 29, 2021, 4:08pm UTC](https://community.dynatrace.com/t/service-naming-using-regex/31212/4 "2021-07-29T16:08:25Z")

</div>

While a good answer, this solution doesn’t completely solve the problem.&nbsp; I’d like to clean up the default name which includes “:80 (/app)” or “:80, :443 (/app)”, etc. and only have the name of the app pool or web request service.&nbsp; The goal here is to clean up these extraneous characters as they are being imported into ServiceNow.

---

<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 29, 2021, 4:31pm UTC](https://community.dynatrace.com/t/service-naming-using-regex/31212/5 "2021-07-29T16:31:31Z")

</div>

What output are you looking for specifically? Can you provide another example? This screenshot shows a preview of how Dave’s rule above would work - does this not match your initial request?

 ![ryan_ott_0-1627576275254.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/2/929d0be6b89a7ca1f11172c7adcb8d592cccf9ee.png)

---

<div class="post-metadata">

**Author:** ![bill\_scheuernst](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/bill_scheuernst/32/2211_2.png) [@bill\_scheuernst](https://community.dynatrace.com/u/bill_scheuernst)\
**Post date:** [July 29, 2021, 4:55pm UTC](https://community.dynatrace.com/t/service-naming-using-regex/31212/6 "2021-07-29T16:55:46Z")

</div>

Solution works.

 ![bill_scheuernst_0-1627577698781.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/3/f32290b9d7191ff64035547c00d322910ee6fe9a.png)

 ![bill_scheuernst_1-1627577738175.png](https://global.discourse-cdn.com/dynatrace/original/2X/6/60d76621db1febf532c21654915948a62899bf7c.png)
