# Manipulate Header Output and Save as Variable

**URL:** <https://community.postman.com/t/manipulate-header-output-and-save-as-variable/50792>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [August 21, 2023, 1:01pm UTC](https://community.postman.com/t/manipulate-header-output-and-save-as-variable/50792 "2023-08-21T13:01:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mackov83](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@mackov83](https://community.postman.com/u/mackov83)\
**Post date:** [August 21, 2023, 1:01pm UTC](https://community.postman.com/t/manipulate-header-output-and-save-as-variable/50792/1 "2023-08-21T13:01:45Z")

</div>

Relatively new to Postman and APIs in general. I am making decent progress, but the following is tripping me up.

I need to store the output of a header called “Link” as a variable, however it contains additional output that I do not need. I can successfully store the output as is with: pm.environment.set(“themeLink”, pm.response.headers.get(“Link”));

Sample header output below:

`<https://10.83.10.111:443/transfer/ef55dc09-59f3-4371-a29e-8a3c37bdf995/upload.zip>;rel="upload:default";type="application/octet-stream"`

How can I capture only `https://10.83.10.111:443/transfer/ef55dc09-59f3-4371-a29e-8a3c37bdf995/upload.zip` and store this as a variable?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [August 21, 2023, 3:49pm UTC](https://community.postman.com/t/manipulate-header-output-and-save-as-variable/50792/2 "2023-08-21T15:49:07Z")

</div>

Hey @mackov83 👋

Welcome to the Postman Community! :postman:

I think using some [regex](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) should help you to extract that value from the header string, you could try something like this:

```javascript
const headerString = pm.response.headers.get('Link'),
    urlValue = headerString.match(/<([^>]+)>/);

pm.environment.set('themeLink', urlValue[1]);

```

---

<div class="post-metadata">

**Author:** ![mackov83](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@mackov83](https://community.postman.com/u/mackov83)\
**Post date:** [August 21, 2023, 11:34pm UTC](https://community.postman.com/t/manipulate-header-output-and-save-as-variable/50792/3 "2023-08-21T23:34:49Z")

</div>

@danny-dainton, thanks very much for the help. That has done the trick!

I will need to spend some time learning regex now 🙂

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [August 28, 2023, 11:35pm UTC](https://community.postman.com/t/manipulate-header-output-and-save-as-variable/50792/4 "2023-08-28T23:35:17Z")

</div>

Closed on August 28, 2023, 11:35pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
