# Help with Regex

**URL:** <https://discourse.haproxy.org/t/help-with-regex/6655>\
**Category:** Help!\
**Created:** [June 16, 2021, 8:08am UTC](https://discourse.haproxy.org/t/help-with-regex/6655 "2021-06-16T08:08:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![senattcs](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@senattcs](https://discourse.haproxy.org/u/senattcs)\
**Post date:** [June 16, 2021, 8:08am UTC](https://discourse.haproxy.org/t/help-with-regex/6655/1 "2021-06-16T08:08:03Z")

</div>

HAProxy receives an header called “X-Cf-Forwarded-Url” with value [https://new-hello-app.apps.px-npe.cf.xxx.com/greeting?name=sen](https://new-hello-app.apps.px-npe.cf.xxx.com/greeting?name=sen) and when HAproxy making backend server call, need to capture “[new-hello-app.apps.px-npe.cf.xxx.com](http://new-hello-app.apps.px-npe.cf.xxx.com)” from X-Cf-Forwarded-Url and set it to “Host” header.

Can someone help with this regex, which need to be used in backend section?

---

<div class="post-metadata">

**Author:** ![rhada](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/rhada/32/585_2.png) [@rhada](https://discourse.haproxy.org/u/rhada)\
**Post date:** [June 21, 2021, 9:46am UTC](https://discourse.haproxy.org/t/help-with-regex/6655/2 "2021-06-21T09:46:29Z")

</div>

Hello,

You can give a try with this :

```auto
http-request set-header host %[req.hdr(X-Cf-Forwarded-Url),regsub(\"(https?://)(.*)(/.*)\",\"\2\",i)] if { req.hdr(X-Cf-Forwarded-Url) -m found }

```

Not sure about the efficiency, but quick test seem OK on version 2.2
