# Get specific data from a string

**URL:** <https://community.n8n.io/t/get-specific-data-from-a-string/10548>\
**Category:** Questions\
**Created:** [January 12, 2022, 3:54am UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548 "2022-01-12T03:54:30Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![0ne](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/0ne/32/9485_2.png) [@0ne](https://community.n8n.io/u/0ne)\
**Post date:** [January 12, 2022, 3:54am UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/1 "2022-01-12T03:54:30Z")

</div>

Something simple that I can figure out how to do or isn’t possible. I have the read email node it returns data, but I want to extract the data I need not having to use the whole string, because I want to update a google sheet with the info but the string contains general info I don’t need

example

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/4/4684853f09148978ddac95e35a92edcf8a06a767.png)

I don’t want the whole text just the NINE which changes on new execution. so pretty much just the part that changes the ticker and I don’t have any coding experience beyond able to figure things out, but this is a necessary node if it doesn’t exist

---

<div class="post-metadata">

**Author:** ![djangelic](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/djangelic/32/9237_2.png) [@djangelic](https://community.n8n.io/u/djangelic)\
**Post date:** [January 12, 2022, 5:26am UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/2 "2022-01-12T05:26:20Z")

</div>

Hi, you can accomplish this with a combination of the SET node and the use of a regular expression (regex). I put together one that should work for your use case, paste this into a new workflow, connect it to the start node, then hit execute. You can then see how the regex value works within the Set node to give you the number nine:

---

<div class="post-metadata">

**Author:** ![0ne](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/0ne/32/9485_2.png) [@0ne](https://community.n8n.io/u/0ne)\
**Post date:** [January 12, 2022, 3:52pm UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/3 "2022-01-12T15:52:57Z")

</div>

I couldnt get it to work heres a copy of my work flow the NINE is the part that changes to randon tickers APPL TSLA etc in the end I just want the ticket by itself to be added to a cell in google sheets

{  
“nodes”: [  
{  
“parameters”: {  
“keepOnlySet”: true,  
“values”: {  
“string”: [  
{  
“name”: “TICKER”,  
“value”: “={{$json[“raw”]}}”  
}  
]  
},  
“options”: {  
“dotNotation”: false  
}  
},  
“name”: “Set”,  
“type”: “n8n-nodes-base.set”,  
“typeVersion”: 1,  
“position”: [  
400,  
200  
]  
},  
{  
“parameters”: {  
“postProcessAction”: “nothing”,  
“format”: “raw”,  
“options”: {  
“customEmailConfig”: “[“UNSEEN”]”,  
“allowUnauthorizedCerts”: true  
}  
},  
“name”: “IMAP Email”,  
“type”: “n8n-nodes-base.emailReadImap”,  
“typeVersion”: 1,  
“position”: [  
0,  
200  
],  
“credentials”: {  
“imap”: {  
“id”: “15”,  
“name”: “IMAP account”  
}  
}  
},  
{  
“parameters”: {  
“operation”: “removeDuplicates”  
},  
“name”: “Item Lists”,  
“type”: “n8n-nodes-base.itemLists”,  
“typeVersion”: 1,  
“position”: [  
220,  
200  
]  
},  
{  
“parameters”: {  
“values”: {  
“string”: [  
{  
“name”: “TICKER”,  
“value”: “TradingView Screener Alert:\nNew Tickers:\nNYSE:NINE”  
}  
]  
},  
“options”: {}  
},  
“name”: “Get initial values”,  
“type”: “n8n-nodes-base.set”,  
“typeVersion”: 1,  
“position”: [  
480,  
20  
]  
},  
{  
“parameters”: {  
“values”: {  
“string”: [  
{  
“name”: "If the value always contains NYSE: ",  
“value”: “={{$json[“TICKER”].match(/(?\<!\w)\w+$/).toString()}}”  
}  
]  
},  
“options”: {}  
},  
“name”: “NYSE”,  
“type”: “n8n-nodes-base.set”,  
“typeVersion”: 1,  
“position”: [  
700,  
20  
]  
}  
],  
“connections”: {  
“IMAP Email”: {  
“main”: [  
[  
{  
“node”: “Item Lists”,  
“type”: “main”,  
“index”: 0  
}  
]  
]  
},  
“Item Lists”: {  
“main”: [  
[  
{  
“node”: “Set”,  
“type”: “main”,  
“index”: 0  
}  
]  
]  
},  
“Get initial values”: {  
“main”: [  
[  
{  
“node”: “NYSE”,  
“type”: “main”,  
“index”: 0  
}  
]  
]  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![djangelic](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/djangelic/32/9237_2.png) [@djangelic](https://community.n8n.io/u/djangelic)\
**Post date:** [January 12, 2022, 4:21pm UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/4 "2022-01-12T16:21:47Z")

</div>

It won’t let me copy this into my n8n instance, you need to make sure you use the \</\> icon in your forum post when pasting in code so I can copy it correctly. If you don’t do that, it introduces weird spaces which means I can’t paste it into my viewer.

---

<div class="post-metadata">

**Author:** ![djangelic](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/djangelic/32/9237_2.png) [@djangelic](https://community.n8n.io/u/djangelic)\
**Post date:** [January 12, 2022, 4:24pm UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/5 "2022-01-12T16:24:09Z")

</div>

It would also help to see a screenshot of the google sheet, or the layout that you are using in the sheet.

---

<div class="post-metadata">

**Author:** ![0ne](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/0ne/32/9485_2.png) [@0ne](https://community.n8n.io/u/0ne)\
**Post date:** [January 12, 2022, 6:18pm UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/6 "2022-01-12T18:18:51Z")

</div>

ok I see let me do that now thank you

I have this spreadsheet and formulas that I use and I want to replace the ticker symbol with symbol I pull for email

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/f/f7c7688af5c596ce9315ea0c2225e3dd580aa532.png)

---

<div class="post-metadata">

**Author:** ![djangelic](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/djangelic/32/9237_2.png) [@djangelic](https://community.n8n.io/u/djangelic)\
**Post date:** [January 12, 2022, 11:11pm UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/7 "2022-01-12T23:11:13Z")

</div>

Ok try this:

---

<div class="post-metadata">

**Author:** ![0ne](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/0ne/32/9485_2.png) [@0ne](https://community.n8n.io/u/0ne)\
**Post date:** [January 13, 2022, 1:12am UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/8 "2022-01-13T01:12:16Z")

</div>

Doesn’t work returns nothing, is there a way to remove matching text from a previous node like if the previous data was 123456 and I say any data that matches 12345 then remove, then im left with 6 as final output. here is screenshot of errors and output.

 ![1 Screenshot](https://europe1.discourse-cdn.com/n8n/original/2X/6/61046c0e04900b0a437c35e4300a5916fd35dcd6.png)  
 ![2 Screenshot](https://europe1.discourse-cdn.com/n8n/original/2X/d/dde8e5a7637da124bf19d21ef5f9c46e400370cf.png)  
 ![3rd Screenshot](https://europe1.discourse-cdn.com/n8n/original/2X/9/94dda507ef7d219827ae5c6d425249c03a52375f.png)  
 ![4 Screenshot](https://europe1.discourse-cdn.com/n8n/original/2X/4/45bc0bd88c81642fb278346c6779ea5c97a7b721.png)

---

<div class="post-metadata">

**Author:** ![djangelic](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/djangelic/32/9237_2.png) [@djangelic](https://community.n8n.io/u/djangelic)\
**Post date:** [January 13, 2022, 4:42pm UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/9 "2022-01-13T16:42:54Z")

</div>

Hi, sorry I am unable to test since I’m not using the imap node. I used the set node to recreate the outputs from your imap and it’s working for me here:

---

<div class="post-metadata">

**Author:** ![0ne](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/0ne/32/9485_2.png) [@0ne](https://community.n8n.io/u/0ne)\
**Post date:** [January 13, 2022, 8:29pm UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/10 "2022-01-13T20:29:15Z")

</div>

> [@djangelic](#):
>

It still doesn’t work but I think I know what the issue is the result comes with a space at the end I had a issue with anothr work flow with space being the issue

---

<div class="post-metadata">

**Author:** ![djangelic](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/djangelic/32/9237_2.png) [@djangelic](https://community.n8n.io/u/djangelic)\
**Post date:** [January 13, 2022, 9:00pm UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/11 "2022-01-13T21:00:29Z")

</div>

Would you mind pasting the values it’s outputting here? I can try again and see if it’s the regex or something else.

---

<div class="post-metadata">

**Author:** ![0ne](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/0ne/32/9485_2.png) [@0ne](https://community.n8n.io/u/0ne)\
**Post date:** [January 14, 2022, 1:07am UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/12 "2022-01-14T01:07:57Z")

</div>

At the end of the ticket theres a small space when I replicate in your flow the space it fail producing just the brackets but when I remove the space it works like intended it would be prefect if it could just return only the part I need “ticker” without space for the IMAP output like SERA only

```auto
[
{
"TICKER": " TradingView Screener Alert: New tickers: NASDAQ:SERA "
},
{
"TICKER": " TradingView Screener Alert: New tickers: NASDAQ:DAVE "
},
{
"TICKER": " TradingView Screener Alert: New tickers: NASDAQ:ONCS "
},
{
"TICKER": " TradingView Screener Alert: New tickers: NASDAQ:MDVL, NASDAQ:SERA "
},
{
"TICKER": " TradingView Screener Alert: New tickers: NASDAQ:BBBY "
},
{
"TICKER": " TradingView Screener Alert: New tickers: NASDAQ:BBBY, NASDAQ:SERA "
},
{
"TICKER": " TradingView Screener Alert: New tickers: NASDAQ:GMVD "
},
{
"TICKER": " TradingView Screener Alert: New tickers: NASDAQ:GMVD, NASDAQ:SERA "
},
{
"TICKER": " TradingView Screener Alert: New tickers: NASDAQ:UK "
},
{
"TICKER": " TradingView Screener Alert: New tickers: NASDAQ:KRMD "
},
{
"TICKER": " TradingView Screener Alert: New tickers: NASDAQ:MBII "
}
]

```

---

<div class="post-metadata">

**Author:** ![djangelic](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/djangelic/32/9237_2.png) [@djangelic](https://community.n8n.io/u/djangelic)\
**Post date:** [January 14, 2022, 5:48pm UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/13 "2022-01-14T17:48:59Z")

</div>

Ahhh Ok I see the issue, let me play with this for a bit.

---

<div class="post-metadata">

**Author:** ![djangelic](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/djangelic/32/9237_2.png) [@djangelic](https://community.n8n.io/u/djangelic)\
**Post date:** [January 14, 2022, 6:11pm UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/14 "2022-01-14T18:11:11Z")

</div>

Ok I think I got it. You should be able to remove the Mock data node and replace it with the Imap node:

---

<div class="post-metadata">

**Author:** ![0ne](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/0ne/32/9485_2.png) [@0ne](https://community.n8n.io/u/0ne)\
**Post date:** [January 15, 2022, 3:24am UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/15 "2022-01-15T03:24:13Z")

</div>

Works, thank you 🥳

---

<div class="post-metadata">

**Author:** ![djangelic](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/djangelic/32/9237_2.png) [@djangelic](https://community.n8n.io/u/djangelic)\
**Post date:** [January 17, 2022, 4:32pm UTC](https://community.n8n.io/t/get-specific-data-from-a-string/10548/16 "2022-01-17T16:32:00Z")

</div>

Glad to hear it 😄 Have fun!
