Optimize the number of text parsers in a scenario

Hi there,

I’m parsing an email in order to get structured data from the text in the email. Each email gives the info about a client booking.

I’m using several Text Parser Match Pattern modules in serial to get the info I get from the text through Regex (see below)

I have around 5-6 modules, but many more to add (probably 20ish)

My question is the following: is there a way to rewrite the scenario so that I don’t have to create a Text Parser/Match Pattern module for each piece of data I want to extract? In other words would there be a way to loop the search and have the Regex change every time an operation is launched based on a list of regex I input? The output could be a Json with all the data corresponding to each Regex

Many thanks!

Welcome to the Make community!

When reaching out for assistance with extracting text, 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

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Ok thank you, will start again with more details.

Here’s the text from the emails I received :

Madame, Monsieur,

Monsieur JAMES MAKE souhaite s’inscrire à la session 25.011 du 01/01/2025 au 31/05/2025 de l’action Prévention, dépistage et suivi des cancers cutanés par le médecin généraliste, Programme intégéré (E-learning) référence(92622425377).

Vous trouverez ci-dessous ses coordonnées et références :

Profession : Médecin
Spécialité : Médecine générale
Courriel : james.make@wanadoo.fr
Frais pédagogiques pris en charge par l’Agence du DPC* : 731.5 €
N° RPPS : 10002866860

I have extracted the following data with Text parsers and Regex in them :
First name (James)
Last name (Make)
Session number (25.001)
Start date
End Date
“référence”
“Profession”
“Spécialité”
“Courriel”
“Frais pédagogiques pris en charge par l’Agence du DPC*”
“N° RPPS”

Here is a screenshot to the scenario. As you can see I have put in series several modules manually to extract each data point

My question is the following: is there a way to loop the scenario on one module with the Regex formula as a variable changing every time the loop is entered with a new input (First name, last name, session number, start date etc.)? I could imagine creating a gsheet database where I have all the data I want to extract in one column and the associated Regex in a another column that would be what the loop would run on.

In my case I was able to manually create all the Text parsers module but in a case I have more (which had happened to me) I want to be able to scale this scenario and not to need to manually create all the modules. For example, over 20 modules it gets really tedious.

Hope that makes things clearer!

Welcome to the Make community!

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

Monsieur (?<firstname>\w+) (?<lastname>\w+) souhaite.+?session (?<session>[\d.+]+) du (?<date1>\S+) au (?<date2>\S+) de .+? référence\((?<ref>\d+)\).\s+.+?\s+Profession : (?<prof>[^\n]+?)\s+Spécialité : (?<spec>[^\n]+?)\s+Courriel : (?<email>[^\n]+?)\s+.+?DPC\*? : (?<price>[^\n]+?) €\s+N° RPPS : (?<rpps>[^\n]+?)(?:\n|\s|$)

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

Important Info

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

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.

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

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.