Regex for lists (GMAIL to List)

Describe the problem/error/question

I am new to n8n, and trying to find regex to simplify a list from a gmail message.

currently, the only way I have found to get the message data is through snippet, which unformats most of the message, including new lines from SMS.

Currently I take a snippet (in mock data) and have been trying to manipulate regex to do my bidding, however I can’t get the replacement I need.

Current Regex used:

([a-z])\s([A-Z])

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

["Item on","e","I","tem tw","o","I","tem three"]
expected output:
["Item one", "Item two", "Item three"]

Information on your n8n setup

  • n8n version: docker 1.52.2
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system: docker

@Grim73 , you could use something like this

{{ $json['mock data'].replaceAll(/ ([A-Z])/g, "\t$1").split('\t') }}

Here I prepend each capital latter preceded by a space with a tabular symbol (\t), which could be anything else instead that is otherwise not expected to be found under normal circumstances. Then the string gets split by that character.

I will plug this in but I actually solved it after digging through regex 101 this is what I setup:

does what I need it to do, but if you (or anyone else) has cleaner way, I am always up to test it out.

for some context, this goes out to my Vikunja instance. have it all running, tested and complete as of right now though!

I do believe the solution I proposed is cleaner. To make it more apparent, here’s the workflow as such:

2 Likes

completely true! thank you so much for your assistance with this. I was trying to get the flow to work with your data, but was still a bit stuck, your solution makes this so much cleaner.

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