Delimit/Extract text

Hey guys,
I’m new to n8n and don’t know JS at all, but I’m trying to simply extract the date from this line:

[ “Date: Tuesday Jan 11th, 2022Drop Off: 10:00 amPick Up: 4:00 pm” ]

I’ve tried using the Function tool but I just don’t know enough to make it work. This is the end result I want:

Jan 11th, 2022

TIA!

1 Like

Hi @siper

Welcome to the n8n community :tada:

Is your data correct? I think it might be like this.

Also, please mention where you’re getting this data.

[
  {
  "Date": "Tuesday Jan 11th, 2022",
  "Drop Off": "10:00 am",
  "Pick Up": "4:00pm"
  }
]

Please confirm. :slight_smile:

or If you feel the data is correct.

Try this workflow. (You can copy and paste in the Workflow Editor)

1 Like

I tried pasting that into a Function node and it didn’t work. Here’s some background. The date itself will be different for each row so that needs to be an Input Name. Basically, I’m downloading my Gmail messages that are confirmations for my dog’s daycare appointments :smile:–I want them to automatically create Google Calendar events for me. I just need to be able to extract the date and format it as a Google Calendar date (i.e. 2022-05-31T19:30:00Z) I’ve gotten this far:

{ "nodes": [ { "parameters": {}, "name": "Start", "type": "n8n-nodes-base.start", "typeVersion": 1, "position": [ 240, 300 ] }, { "parameters": { "resource": "message", "operation": "getAll", "additionalFields": { "format": "resolved" } }, "name": "Gmail", "type": "n8n-nodes-base.gmail", "typeVersion": 1, "position": [ 400, 300 ], "credentials": { "gmailOAuth2": { "id": "3", "name": "Gmail account" } } }, { "parameters": { "conditions": { "string": [ { "value1": "={{$json[\"Text\"]}}", "operation": "=contains", "value2": "Your registration for Dave at Muttassori has been approved" } ] } }, "name": "IF", "type": "n8n-nodes-base.if", "typeVersion": 1, "position": [ 720, 300 ] }, { "parameters": { "keepOnlySet": true, "values": { "string": [ { "name": "Text", "value": "={{$json[\"text\"]}}" }, { "name": "MessageID", "value": "={{$json[\"messageId\"]}}" }, { "name": "HTML", "value": "={{$json[\"textAsHtml\"]}}" } ] }, "options": {} }, "name": "Set", "type": "n8n-nodes-base.set", "typeVersion": 1, "position": [ 560, 300 ] }, { "parameters": { "dataPropertyName": "=HTML", "extractionValues": { "values": [ { "key": "Dates", "cssSelector": "p:nth-child(3)", "returnArray": true } ] }, "options": { "trimValues": true } }, "name": "HTML Extract", "type": "n8n-nodes-base.htmlExtract", "typeVersion": 1, "position": [ 900, 280 ] } ], "connections": { "Start": { "main": [ [ { "node": "Gmail", "type": "main", "index": 0 } ] ] }, "Gmail": { "main": [ [ { "node": "Set", "type": "main", "index": 0 } ] ] }, "IF": { "main": [ [ { "node": "HTML Extract", "type": "main", "index": 0 } ] ] }, "Set": { "main": [ [ { "node": "IF", "type": "main", "index": 0 } ] ] } } }

Am I on the right track?