Text Parser to Google Sheets - 3 bundles to 3 different columns (now 3 different rows)

In a document, I have something like this:
##Column A (Heading)
Paragraph B (Content)
##Column B (Heading)
Paragraph B (Content)
#Column C (Heading)
Paragraph C (Content)

I want to bring in the “Paragraph A”, “Paragraph B” and “Paragraph C” (i.e the content) to my google Sheets in a new row. I don’t want each of them to be in new rows, but in the same row in 3 different columns. The columns will already have a header called “Column A”, “Column B” and “Column C”.

I used the “Text Parser” “Match Pattern” and put in the pattern “##([^\n]+)\n([\s\S]*?)(?=##|$)”

This gave me an output of 3 bundles each with “i”, “$1” (Heading) and “$2” (Content).

I’ve tried all ways to bring the $2 for each bundle into Google sheets - into Column A/B/C. I’ve tried using Array Agreegator, Iterator, set variables, etc. I still can’t get he Content from the 3 bundles into one row in Google Sheets - put into 3 separate columns.

When opening up Google Sheets, even though I see 3 separate columns (A), (B), (C), I am not able to match to the “Content” from the 3 different bundles.

If someone could help, that would be great. THanks.

Welcome to the Make community!

You can use a Text Parser “Match Pattern” module with this Pattern (regular expression):

#+.+\s+([^#]+?)\s*#+.+\s+([^#]+?)\s*#+.+\s+([^#]+)

Proof https://regex101.com/r/023jZL/1

Important Info

  • :warning: Global match must be set to NO!

Screenshot

Output

Screenshot_2024-07-31_170759


For more information, see Text Parser in the Make Help Center:

Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

Hope this helps! Let me know if there are any further questions or issues.

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

Wow Sam, thank you so much. I’ve been spending hours trying to figure this out. Appreciate your quick help.

A quick follow up if possible. I just put 3 sets of headings and paragraphs - A, B, C. But in reality I may have many sets - not sure of the exact number. I realize the REgex works with 3 sets only. But what if there are many (not sure exactly how many) and i need to use “global”? How would I need to change this then? Thanks

PS: Fellow Sinaporean here and who has lived in Australia/Perth before!

1 Like

Hi Jon,

In that case, if you do not know how many sets, we will have to use the “Global match” option.

Here is the updated pattern and instructions:

You can use a Text Parser “Match Pattern” module with this Pattern (regular expression):

#+.+\s+(?<paragraph>[^#]+)(?:\n\n|$)

Proof https://regex101.com/r/fbRnWd/1

Important Info

  • :warning: Global match must be set to YES!

Screenshot

Aggregate Matches

Then, you will need to combine the matches into a single bundle so you can map all of the matches at the same time.

Output

Screenshot_2024-07-31_210705

Module Export

You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.

  1. Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.

  3. Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.

Click to Expand Module Export Code

JSON - Copy and Paste this directly in the scenario editor

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 139,
                    "module": "util:ComposeTransformer",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "value": "## Column A (Heading)\nParagraph A (Content)\n\n## Column B (Heading)\n\nParagraph B (Content)\nParagraph B (Content)\nParagraph B (Content)\nParagraph B (Content)\n\n## Column C (Heading)\nParagraph C (Content)"
                    },
                    "metadata": {
                        "designer": {
                            "x": 2528,
                            "y": -1417
                        },
                        "restore": {},
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ]
                    }
                },
                {
                    "id": 140,
                    "module": "regexp:Parser",
                    "version": 1,
                    "parameters": {
                        "pattern": "#+.+\\s+(?<paragraph>[^#]+)(?:\\n\\n|$)",
                        "global": true,
                        "sensitive": true,
                        "multiline": false,
                        "singleline": false,
                        "continueWhenNoRes": false,
                        "ignoreInfiniteLoopsWhenGlobal": false
                    },
                    "mapper": {
                        "text": "{{139.value}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 2772,
                            "y": -1421
                        },
                        "restore": {
                            "parameters": {
                                "sensitive": {
                                    "collapsed": true
                                },
                                "multiline": {
                                    "collapsed": true
                                },
                                "singleline": {
                                    "collapsed": true
                                },
                                "continueWhenNoRes": {
                                    "collapsed": true
                                }
                            }
                        },
                        "parameters": [
                            {
                                "name": "pattern",
                                "type": "text",
                                "label": "Pattern",
                                "required": true
                            },
                            {
                                "name": "global",
                                "type": "boolean",
                                "label": "Global match",
                                "required": true
                            },
                            {
                                "name": "sensitive",
                                "type": "boolean",
                                "label": "Case sensitive",
                                "required": true
                            },
                            {
                                "name": "multiline",
                                "type": "boolean",
                                "label": "Multiline",
                                "required": true
                            },
                            {
                                "name": "singleline",
                                "type": "boolean",
                                "label": "Singleline",
                                "required": true
                            },
                            {
                                "name": "continueWhenNoRes",
                                "type": "boolean",
                                "label": "Continue the execution of the route even if the module finds no matches",
                                "required": true
                            },
                            {
                                "name": "ignoreInfiniteLoopsWhenGlobal",
                                "type": "boolean",
                                "label": "Ignore errors when there is an infinite search loop",
                                "required": true
                            }
                        ],
                        "expect": [
                            {
                                "name": "text",
                                "type": "text",
                                "label": "Text"
                            }
                        ],
                        "interface": [
                            {
                                "type": "text",
                                "name": "paragraph",
                                "label": "paragraph"
                            },
                            {
                                "type": "uinteger",
                                "name": "i",
                                "label": "i"
                            },
                            {
                                "type": "any",
                                "name": "__IMTMATCH__",
                                "label": "Fallback Match"
                            }
                        ]
                    }
                },
                {
                    "id": 141,
                    "module": "builtin:BasicAggregator",
                    "version": 1,
                    "parameters": {
                        "feeder": 140
                    },
                    "mapper": {
                        "paragraph": "{{140.paragraph}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 3014,
                            "y": -1422,
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {
                            "extra": {
                                "feeder": {
                                    "label": "Text parser - Match pattern [140]"
                                },
                                "target": {
                                    "label": "Custom"
                                }
                            }
                        }
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

Hope this helps! Let me know if there are any further questions or issues.

Join the Make Fans Discord server to chat with other makers!

1 Like

Thank you Sam. Appreciate your help and the effort you’ve put into it so much! Cheers!

No problem, glad I could help!

1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

Here are some useful links and guides you can use to learn more on how to use the Make platform, apps, and app modules. I found these useful when I was learning Make, and hope they might benefit you too —

Getting Started

Help Centre Basics

Articles & Videos

Partner & Custom Apps

Hope this helps! Let me know if there are any further questions or issues.

You can also join us in the Make Fans Discord server to chat with other makers. Due to the evolving needs of this community, the Discord invite link can be found elsewhere on this forum. You can either search for it or request an invite.