Incorrectly truncated text parsing

Hi,

I’m having trouble parsing match pattern text to map to Airtable fields and ultimately to WordPress. This is my first time using a text parser, so I’m not sure if this is correct or not, but when I identify the pattern, it either parses incorrectly, truncates it, or doesn’t parse anything at all.

Here is the search pattern expression I’m using:

Here is the text I need to parse:

And here’s the blueprint:
blueprint (1).json (135.8 KB)

Thanks for your help!

Welcome to the Make community!

When reaching out for assistance with your regex pattern for a Text Parser module, it would be super helpful if you could share the actual text you’re trying to match. Screenshots of text can be a bit tricky, so if you could copy and paste the text directly here, that would be awesome! It ensures we can run it against test patterns effectively. If there’s any sensitive info, feel free to change it to something fictional yet still valid by keeping the format intact.

Providing clear text examples saves time on both ends and helps us give you the best possible solution. Without proper examples, we might end up playing a guessing game, and nobody wants that as it is a waste of time! You are more likely to get a correct answer faster. So, help us help you by sharing those text snippets.

Please format the example text this way to preserve line breaks and special characters:

These are the two ways to format text so that it won’t be modified by the forum:

  • Method 1: Type code block manually

    Add three backticks ``` before and after the content/bundle, like this:

    ```
    content goes here
    ```

  • Method 2. Highlight and click the format button in the editor

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

@samliew

Okay, here’s the correctly formatted text output from Claude:


[SLUG]ghana-cocoa-supply-shortfall-impacts-traders[/SLUG]

[TITLE]Sweet Trouble: Ghana's Cocoa Shortfall Leaves Traders in a Bitter Spot[/TITLE]

[EXCERPT]Ghana's cocoa bean delivery hiccup has traders facing a whopping $1 billion loss. Here's what happened and why it matters for your morning mocha.[/EXCERPT]

[BODY]
<p>Hey there, chocolate lovers and market watchers! Grab your favorite cocoa-based snack because we've got some news that might make your wallet feel a little lighter (but hopefully not your candy bar).</p>

<h2>The Scoop on the Cocoa Chaos</h2>

<p>Reuters just dropped an exclusive report that's shaking up the cocoa world. Here's what you need to know:</p>

<ul>
<li>🍫 Trading houses are staring down the barrel of a $1 billion loss. Ouch!</li>
<li>🇬🇭 Ghana, a major cocoa producer, couldn't deliver the beans this year. Talk about a supply chain hiccup!</li>
<li>📉 Traders had to scramble to cover their positions in a market that's been heading up, up, up.</li>
</ul>

<h2>Why This Matters</h2>

<p>You might be thinking, "So what? I'm not a cocoa trader." But hold on to your chocolate bars, because this could affect more than just the folks in fancy suits:</p>

<ul>
<li>🍪 Your favorite treats might get pricier. When cocoa costs more, so does everything made with it.</li>
<li>💼 It's a wake-up call for how vulnerable global supply chains can be.</li>
<li>🌍 This could impact Ghana's economy and potentially other cocoa-producing nations.</li>
</ul>

<h2>Market Impact: More Than Just a Hill of Beans</h2>

<p>Let's break down what this cocoa conundrum could mean for the markets:</p>

<ul>
<li>📈 Cocoa futures are likely to stay volatile. Keep an eye on the iPath Bloomberg Cocoa Subindex Total Return ETN (NIB) if you're into that sort of thing.</li>
<li>🍫 Big chocolate producers like Hershey (HSY) and Mondelez (MDLZ) might see their costs go up, which could squeeze their profits.</li>
<li>🚜 Agricultural commodity traders like Archer-Daniels-Midland (ADM) could face some headwinds.</li>
<li>🌱 This might boost interest in alternative sweeteners and plant-based chocolate substitutes. Companies in this space could see increased attention.</li>
</ul>

<p>So there you have it, folks. A billion-dollar bean blunder that's got traders sweating and could have us all digging a little deeper for our chocolate fix. Keep your eyes peeled for how this plays out – it's sure to be a wild ride in the world of cocoa!</p>
[/BODY]

[CATEGORIES]Finance,Commodities,Global Trade[/CATEGORIES]

[TAGS]cocoa,Ghana,commodities,trading,supplychain,chocolate

And here’s an example of the one of the regex patter texts:

[SLUG]([\s\S]*?)[/SLUG]

Welcome to the Make community!

Yes, that is possible. You’ll need a minimum of two modules, a Text Parser and an Array Aggregator.

You can use a Text Parser “Match Pattern” module with this Pattern (regular expression), to match all the content in the tags.

\[(?<tag>[^\]]+)]\s*(?<content>[\w\W]+?)\s*\[\/\1]

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

One module matches all tags.

Important Info

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

Screenshot

Output


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.


Then, use an Array Aggregator to combine all the matches into a single bundle.

Screenshot_2024-08-09_080849 (2)

Output

Screenshot_2024-08-09_080840

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

@samliew

2 Likes

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": 206,
                    "module": "util:ComposeTransformer",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "value": "[SLUG]ghana-cocoa-supply-shortfall-impacts-traders[/SLUG]\n\n[TITLE]Sweet Trouble: Ghana's Cocoa Shortfall Leaves Traders in a Bitter Spot[/TITLE]\n\n[EXCERPT]Ghana's cocoa bean delivery hiccup has traders facing a whopping $1 billion loss. Here's what happened and why it matters for your morning mocha.[/EXCERPT]\n\n[BODY]\n<p>Hey there, chocolate lovers and market watchers! Grab your favorite cocoa-based snack because we've got some news that might make your wallet feel a little lighter (but hopefully not your candy bar).</p>\n\n<h2>The Scoop on the Cocoa Chaos</h2>\n\n<p>Reuters just dropped an exclusive report that's shaking up the cocoa world. Here's what you need to know:</p>\n\n<ul>\n<li>🍫 Trading houses are staring down the barrel of a $1 billion loss. Ouch!</li>\n<li>🇬🇭 Ghana, a major cocoa producer, couldn't deliver the beans this year. Talk about a supply chain hiccup!</li>\n<li>📉 Traders had to scramble to cover their positions in a market that's been heading up, up, up.</li>\n</ul>\n\n<h2>Why This Matters</h2>\n\n<p>You might be thinking, \"So what? I'm not a cocoa trader.\" But hold on to your chocolate bars, because this could affect more than just the folks in fancy suits:</p>\n\n<ul>\n<li>🍪 Your favorite treats might get pricier. When cocoa costs more, so does everything made with it.</li>\n<li>💼 It's a wake-up call for how vulnerable global supply chains can be.</li>\n<li>🌍 This could impact Ghana's economy and potentially other cocoa-producing nations.</li>\n</ul>\n\n<h2>Market Impact: More Than Just a Hill of Beans</h2>\n\n<p>Let's break down what this cocoa conundrum could mean for the markets:</p>\n\n<ul>\n<li>📈 Cocoa futures are likely to stay volatile. Keep an eye on the iPath Bloomberg Cocoa Subindex Total Return ETN (NIB) if you're into that sort of thing.</li>\n<li>🍫 Big chocolate producers like Hershey (HSY) and Mondelez (MDLZ) might see their costs go up, which could squeeze their profits.</li>\n<li>🚜 Agricultural commodity traders like Archer-Daniels-Midland (ADM) could face some headwinds.</li>\n<li>🌱 This might boost interest in alternative sweeteners and plant-based chocolate substitutes. Companies in this space could see increased attention.</li>\n</ul>\n\n<p>So there you have it, folks. A billion-dollar bean blunder that's got traders sweating and could have us all digging a little deeper for our chocolate fix. Keep your eyes peeled for how this plays out – it's sure to be a wild ride in the world of cocoa!</p>\n[/BODY]\n\n[CATEGORIES]Finance,Commodities,Global Trade[/CATEGORIES]\n\n[TAGS]cocoa,Ghana,commodities,trading,supplychain,chocolate[/TAGS]"
                    },
                    "metadata": {
                        "designer": {
                            "x": 1242,
                            "y": -2940
                        },
                        "restore": {},
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ]
                    }
                },
                {
                    "id": 207,
                    "module": "regexp:Parser",
                    "version": 1,
                    "parameters": {
                        "pattern": "\\[(?<tag>[^\\]]+)]\\s*(?<content>[\\w\\W]+?)\\s*\\[\\/\\1]",
                        "global": true,
                        "sensitive": true,
                        "multiline": false,
                        "singleline": false,
                        "continueWhenNoRes": false,
                        "ignoreInfiniteLoopsWhenGlobal": false
                    },
                    "mapper": {
                        "text": "{{206.value}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 1488,
                            "y": -2940
                        },
                        "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": "tag",
                                "label": "tag"
                            },
                            {
                                "type": "text",
                                "name": "content",
                                "label": "content"
                            },
                            {
                                "type": "uinteger",
                                "name": "i",
                                "label": "i"
                            },
                            {
                                "type": "any",
                                "name": "__IMTMATCH__",
                                "label": "Fallback Match"
                            }
                        ]
                    }
                },
                {
                    "id": 208,
                    "module": "builtin:BasicAggregator",
                    "version": 1,
                    "parameters": {
                        "feeder": 207
                    },
                    "mapper": {
                        "tag": "{{207.tag}}",
                        "content": "{{207.content}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 1731,
                            "y": -2940
                        },
                        "restore": {
                            "extra": {
                                "feeder": {
                                    "label": "Text parser - Match pattern [207]"
                                },
                                "target": {
                                    "label": "Custom"
                                }
                            }
                        }
                    }
                },
                {
                    "id": 209,
                    "module": "util:SetVariable2",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "name": "variables",
                        "scope": "roundtrip",
                        "value": "{{toCollection(208.array; \"tag\"; \"content\")}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": 1976,
                            "y": -2941
                        },
                        "restore": {
                            "expect": {
                                "scope": {
                                    "label": "One cycle"
                                }
                            }
                        },
                        "expect": [
                            {
                                "name": "name",
                                "type": "text",
                                "label": "Variable name",
                                "required": true
                            },
                            {
                                "name": "scope",
                                "type": "select",
                                "label": "Variable lifetime",
                                "required": true,
                                "validate": {
                                    "enum": [
                                        "roundtrip",
                                        "execution"
                                    ]
                                }
                            },
                            {
                                "name": "value",
                                "type": "any",
                                "label": "Variable value"
                            }
                        ],
                        "interface": [
                            {
                                "name": "variables",
                                "label": "variables",
                                "type": "any"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

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

@samliew

1 Like

Wow! Thank you soooo much!

I have another question in that same automation that is stumping me.

I want to then send these to Airtable and then straight to Wordpress. When I try to search for the tags and categories I sent through the parser and create a new one if one doesn’t already exist, Wordpress does not recognize it because it’s not a defined integer.

How would I send that over?

Thank you again!

No problem, glad I could help!

Please always start a new thread for your new question, as I am unsure if I can answer it.

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.

@samliew