Get specific data from a string

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

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

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:

1 Like

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
}
]
]
}
}
}

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.

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

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

Ok try this:

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.




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:

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

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

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

[
{
"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 "
}
]

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

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

1 Like

Works, thank you :partying_face:

1 Like

Glad to hear it :smile: Have fun!

1 Like