# cleanup Url Regex for session properties

**URL:** <https://community.dynatrace.com/t/cleanup-url-regex-for-session-properties/35384>\
**Category:** Real User Monitoring\
**Tags:** application-monitoring\
**Created:** [June 6, 2022, 1:26pm UTC](https://community.dynatrace.com/t/cleanup-url-regex-for-session-properties/35384 "2022-06-06T13:26:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yann\_Buccellato](https://avatars.discourse-cdn.com/v4/letter/y/97f17d/32.png) [@Yann\_Buccellato](https://community.dynatrace.com/u/Yann_Buccellato)\
**Post date:** [June 6, 2022, 1:26pm UTC](https://community.dynatrace.com/t/cleanup-url-regex-for-session-properties/35384/1 "2022-06-06T13:26:14Z")

</div>

Hi,

we are trying to configure a clean up rule for many different urls contained in the “Referer” parameter.

At capture time (for user action properties) we can see those and many other values:

> **[Google](http://www.google.it)**
>
> Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.

> **[Google](https://www.google.com/)**
>
> Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.

> **[Yahoo | Mail, Weather, Search, Politics, News, Finance, Sports & Videos](https://www.yahoo.com/)**
>
> Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!

> **[TransAtlantic Airways - Air Cargo, GSA](https://transatlantic.com/)**
>
> Copyright TransAtlantic Airways 2024 All Rights Reserved.

ecc…

we would like to clean up those values from the “.it”, “.com”, “[https://www](https://www).”, “http://” to transform them in, per example:

google

yahoo

transatlantic

as of now we have managed to have a partial regex but we are struggling to achieve the desidered result.  
Can somebody help out?

Thank you

---

<div class="post-metadata">

**Author:** ![AlexOsbourn](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@AlexOsbourn](https://community.dynatrace.com/u/AlexOsbourn)\
**Post date:** [June 9, 2022, 3:40pm UTC](https://community.dynatrace.com/t/cleanup-url-regex-for-session-properties/35384/2 "2022-06-09T15:40:18Z")

</div>

Try something like this:

```auto
^https?:\/\/w{0,3}\.?(.*)\.[a-zA-Z]{2,63}$

```

I haven’t tried this in Dynatrace but it certainly works in regular regex. It assumes that all URLs will contain either HTTP or HTTPS and ends in a valid TLD between 2 and 63 characters.

---

<div class="post-metadata">

**Author:** ![mgome](https://avatars.discourse-cdn.com/v4/letter/m/958977/32.png) [@mgome](https://community.dynatrace.com/u/mgome)\
**Post date:** [June 9, 2022, 6:25pm UTC](https://community.dynatrace.com/t/cleanup-url-regex-for-session-properties/35384/3 "2022-06-09T18:25:57Z")

</div>

You’re not going to be able to isolate the cleanup rule to just .it and .com because of the lack of lookahead in the regex engine. The following will get you the string between the first and second period:

\.([^\.]\*+)
