Help

Re: Split text into new columns, unclear delimeter

Solved
Jump to Solution
2347 1
cancel
Showing results for 
Search instead for 
Did you mean: 
aliona
4 - Data Explorer
4 - Data Explorer

Hi,

I need help to split this string into four pieces and put them in four new columns…

Maybe split two times with different delimeters?

{“email":"mail@gmail.com”,“firstname”:“John”,“lastname”:“Hong”,“phone”:“1234567”}

Column 1: mail@gmail.com
Column 2: John
Column 3: Hong
Column 4: 1234567

Thanks in advance!

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

Welcome to the Airtable community!

image

I approached this with regular expressions.

Here is the formula for the email:

REGEX_REPLACE(
  REGEX_EXTRACT({text}, '"email":"[^"]+"'),
  '("email":")([^"]+)(")',
  '$2'
)

Here is the formula for the firstname:

REGEX_REPLACE(
  REGEX_EXTRACT({text}, '"firstname":"[^"]+"'),
  '("firstname":")([^"]+)(")',
  '$2'
)

Hopefully you can figure out the other two fields from these two examples.

Some notes:

  • I had to change some curly quotes to straight quotes. I’m guessing that your original text has straight quotes because it looks like a JSON string, which uses straight quotes. Often when pasting in text to the forum, the forum software converts straight quotes to curly quotes.
  • This formula assumes that there will be data. If there is missing data, you will get an error. If any of the fields might be missing, the formula can be adjusted to return blank.
  • This formula assumes that there will be no double quotes inside any of the actual values.
  • This formula assumes that the spacing will be consistent (no spaces except inside actual values).
  • This formula assumes that things that look like numbers are actually strings, as is the case with “phone”. If you have an actual number, you will need a slightly different formula.
  • If you want any of the more complex formulas that I describe, feel free to book at meeting with me.

See Solution in Thread

4 Replies 4
Tim_Mackey
6 - Interface Innovator
6 - Interface Innovator

Unfortunately, Airtable formulas do not have proper string splitting functions or array handlers, so it’s a nightmare trying to do this in a formula. If you really want to attempt it, here are a couple threads that discuss the issue:

If you are on a plan that supports automations, you’ll likely be better off using an automation to parse these values for you, since dealing with JSON is trivial within a Script Action. Sorry to not have better news!

Hi, and thanks for answering… do you mean automation with a script or what kind of automation? My plan supports automations.

Where is the data coming from? You could potentially use a tool like Zapier or Make.com to split the data before sending it to Airtable.

kuovonne
18 - Pluto
18 - Pluto

Welcome to the Airtable community!

image

I approached this with regular expressions.

Here is the formula for the email:

REGEX_REPLACE(
  REGEX_EXTRACT({text}, '"email":"[^"]+"'),
  '("email":")([^"]+)(")',
  '$2'
)

Here is the formula for the firstname:

REGEX_REPLACE(
  REGEX_EXTRACT({text}, '"firstname":"[^"]+"'),
  '("firstname":")([^"]+)(")',
  '$2'
)

Hopefully you can figure out the other two fields from these two examples.

Some notes:

  • I had to change some curly quotes to straight quotes. I’m guessing that your original text has straight quotes because it looks like a JSON string, which uses straight quotes. Often when pasting in text to the forum, the forum software converts straight quotes to curly quotes.
  • This formula assumes that there will be data. If there is missing data, you will get an error. If any of the fields might be missing, the formula can be adjusted to return blank.
  • This formula assumes that there will be no double quotes inside any of the actual values.
  • This formula assumes that the spacing will be consistent (no spaces except inside actual values).
  • This formula assumes that things that look like numbers are actually strings, as is the case with “phone”. If you have an actual number, you will need a slightly different formula.
  • If you want any of the more complex formulas that I describe, feel free to book at meeting with me.