Parsing Text With Formulas

I want to ingest text in the following format:

Header 1:

  • Bullet 1.1…
  • Bullet 1.2…

Header 2:

  • Bullet 2.1…
  • Bullet 2.2…

Header 3:

  • Bullet 3.1…
  • Bullet 3.2…

And convert it into 3 separate text variables that only contains the bullet points of that particular section.

Is there a way to parse the text into these variables using weweb formulas?

You can definitely parse text using some combination of weweb formulas and light javascript, but the “how” will be sensitive to the exact text you’re looking to parse.

If you care to share that text, try using the “code” icon in the reply editor to make three backtick marks in a row, like so, to illustrate the exact characters:

this is a code sample

The specific text would be different every time. The only constant between instances would be the headers. The rest follows the structure above.

Here’s what I would do:

  1. Create an array variable that will contain the split text
  2. Parse the text using a JS function
const regex = /- (.+?)…/g;
const bulletPointValues = [];

let match;
while ((match = regex.exec(text)) !== null) {
  bulletPointValues.push(match[1]);
}

console.log(bulletPointValues);
  1. Using the right bullet point from the variable (from 1) by using the right index, as the text would now be like this:
[
  'Bullet 1.1',
  'Bullet 1.2',
  'Bullet 2.1',
  'Bullet 2.2',
  'Bullet 3.1',
  'Bullet 3.2'
]