# request attribute - Web request URL - regex - extract second part of URI

**URL:** <https://community.dynatrace.com/t/request-attribute-web-request-url-regex-extract-second-part-of-uri/13158>\
**Category:** Open Q&A\
**Tags:** request-attributes\
**Created:** [June 27, 2018, 7:41pm UTC](https://community.dynatrace.com/t/request-attribute-web-request-url-regex-extract-second-part-of-uri/13158 "2018-06-27T19:41:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yosi\_Neuman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/yosi_neuman/32/9845_2.png) [@Yosi\_Neuman](https://community.dynatrace.com/u/Yosi_Neuman)\
**Post date:** [June 27, 2018, 7:41pm UTC](https://community.dynatrace.com/t/request-attribute-web-request-url-regex-extract-second-part-of-uri/13158/1 "2018-06-27T19:41:50Z")

</div>

Hi guys,

What should be the right regex in order to extract the second part of the URI?

In the followed example we would like to get vh3

 ![17294-second-uri.png](https://global.discourse-cdn.com/dynatrace/original/2X/5/570c9a2501967354f29516a76077e29de3fc2031.png)

---

<div class="post-metadata">

**Author:** ![JamesKitson](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/jameskitson/32/22460_2.png) [@JamesKitson](https://community.dynatrace.com/u/JamesKitson)\
**Post date:** [June 27, 2018, 8:18pm UTC](https://community.dynatrace.com/t/request-attribute-web-request-url-regex-extract-second-part-of-uri/13158/2 "2018-06-27T20:18:48Z")

</div>

media\/([^\/?]\*+) might work if you’re only interested in that specific pattern. I was trying to test it but it seems to keep crashing my page.

For reference here’s a good doc on regex in Dynatrace: [Regular expressions in Dynatrace — Dynatrace Docs](https://www.dynatrace.com/support/help/organize-monitored-entities/reference/how-do-i-use-regular-expressions-in-dynatrace/)

James

---

<div class="post-metadata">

**Author:** ![Yosi\_Neuman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/yosi_neuman/32/9845_2.png) [@Yosi\_Neuman](https://community.dynatrace.com/u/Yosi_Neuman)\
**Post date:** [June 28, 2018, 2:14am UTC](https://community.dynatrace.com/t/request-attribute-web-request-url-regex-extract-second-part-of-uri/13158/3 "2018-06-28T02:14:16Z")

</div>

Hi James,

Thanks for your answer

I read this page and tried few times different ways with no luck…

Your regex seem to invalid

 ![17297-invalid-reg.png](https://global.discourse-cdn.com/dynatrace/original/2X/3/3217b4bbbeb37397522039ecf4f190c1dd70060d.png)

---

<div class="post-metadata">

**Author:** ![gilgi](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gilgi/32/11747_2.png) [@gilgi](https://community.dynatrace.com/u/gilgi)\
**Post date:** [June 28, 2018, 5:18am UTC](https://community.dynatrace.com/t/request-attribute-web-request-url-regex-extract-second-part-of-uri/13158/4 "2018-06-28T05:18:59Z")

</div>

post processing options allow for splitting the values, which will create an array of the different parts (assuming the delimiter is /). The question is how do I retrieve only the second element of that array

---

<div class="post-metadata">

**Author:** ![michael\_kopp](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/michael_kopp/32/13415_2.png) [@michael\_kopp](https://community.dynatrace.com/u/michael_kopp)\
**Post date:** [June 28, 2018, 12:04pm UTC](https://community.dynatrace.com/t/request-attribute-web-request-url-regex-extract-second-part-of-uri/13158/5 "2018-06-28T12:04:19Z")

</div>

the split actually puts multiple values on the request, so that is not what you want here.

instead of that remove the split ad do a regex that will go for the second part. this regex should do the trick, it jumps over part one and takes part two.

/[^/]++/([^/]++)

---

<div class="post-metadata">

**Author:** ![Yosi\_Neuman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/yosi_neuman/32/9845_2.png) [@Yosi\_Neuman](https://community.dynatrace.com/u/Yosi_Neuman)\
**Post date:** [June 28, 2018, 1:47pm UTC](https://community.dynatrace.com/t/request-attribute-web-request-url-regex-extract-second-part-of-uri/13158/6 "2018-06-28T13:47:02Z")

</div>

Thanks Michael

This one is look working

 ![17306-look-ok.png](https://global.discourse-cdn.com/dynatrace/original/3X/d/2/d26172ee6c2eaaa962dd39dae2b759b5ede8367d.png)
