# Extracting part of string as a collection variable

**URL:** <https://community.postman.com/t/extracting-part-of-string-as-a-collection-variable/62190>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [June 13, 2024, 4:39pm UTC](https://community.postman.com/t/extracting-part-of-string-as-a-collection-variable/62190 "2024-06-13T16:39:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![flight-administrat15](https://avatars.discourse-cdn.com/v4/letter/f/ce73a5/32.png) [@flight-administrat15](https://community.postman.com/u/flight-administrat15)\
**Post date:** [June 13, 2024, 4:39pm UTC](https://community.postman.com/t/extracting-part-of-string-as-a-collection-variable/62190/1 "2024-06-13T16:39:43Z")

</div>

Hi. I’d like to extract this part of URL property as a collection variable. Having only that piece of code, it extracts the whole string. I’d like to get only the part after the equal sign.

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/e/8/e8fd375ff822f89f13af57be31dc7861df52e20a.png)

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/b/c/bcf0574a65b74475f2f4b60483e15ae7406b3ce4.png)

I’ll be grateful for the help!

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [June 14, 2024, 11:53am UTC](https://community.postman.com/t/extracting-part-of-string-as-a-collection-variable/62190/2 "2024-06-14T11:53:13Z")

</div>

You can use the JavaScript Split() method.

```auto
let URL = "https://somewebsite.com/somepath&session_id=123456"
let session_id = URL.split('=')[1]
console.log(session_id); // "123456"

```

---

<div class="post-metadata">

**Author:** ![flight-administrat15](https://avatars.discourse-cdn.com/v4/letter/f/ce73a5/32.png) [@flight-administrat15](https://community.postman.com/u/flight-administrat15)\
**Post date:** [June 14, 2024, 3:19pm UTC](https://community.postman.com/t/extracting-part-of-string-as-a-collection-variable/62190/3 "2024-06-14T15:19:32Z")

</div>

Thanks! Adding split() after URL did the trick:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/c/d/cd11a7ac60014979d5fabdcad73c3eb0d5f76b2a.png)

![image](https://us1.discourse-cdn.com/getpostman/original/3X/5/1/51cb25553642e957ccdde6918e00fb1cf08fae4d.png)

---

<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:** [June 17, 2024, 3:19pm UTC](https://community.postman.com/t/extracting-part-of-string-as-a-collection-variable/62190/4 "2024-06-17T15:19:54Z")

</div>

Closed on June 17, 2024, 3:19pm UTC

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