# Gmail =\> google sheets (text parser)

**URL:** <https://community.make.com/t/gmail-google-sheets-text-parser/26234>\
**Category:** Questions\
**Tags:** text-parser\
**Created:** [February 2, 2024, 10:16am UTC](https://community.make.com/t/gmail-google-sheets-text-parser/26234 "2024-02-02T10:16:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Exam\_Fox](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@Exam\_Fox](https://community.make.com/u/Exam_Fox)\
**Post date:** [February 2, 2024, 10:16am UTC](https://community.make.com/t/gmail-google-sheets-text-parser/26234/1 "2024-02-02T10:16:34Z")

</div>

Hello,

I have a problem and I don’t know what solution is best to use.  
I receive an email with the following syntax:

Invoice no.: 6089856/13/2024/F  
Amount to be paid:  
$424.45  
payment date  
13/02/2024

Invoice no.: 7089856/13/2024/F  
Amount to be paid:  
$324.45  
payment date  
14/02/2024

Invoice no.: 8089856/13/2024/F  
Amount to be paid:  
USD 224.45  
payment date  
15/02/2024

I want the above information to be transferred to Google Sheets as follows:  
column A - 6089856/13/2024/F  
column B - USD 424.45  
column C - 13/02/2024

What’s the best way to approach the topic? Use text parser (match pattern) or is there another way?

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [February 2, 2024, 11:57am UTC](https://community.make.com/t/gmail-google-sheets-text-parser/26234/2 "2024-02-02T11:57:45Z")

</div>

Welcome to the Make community!

You can use a Text Parser “[Match Pattern](https://www.make.com/en/help/tools/text-parser)” module with this regular expression pattern

`Invoice no\.:\s+(?<invoice>[^\n]+)\s+Amount to be paid:\s+(?:\$|USD\s)(?<amount>\d[\d,]+(?:\.\d{2})?)\s+payment date\s+(?<date>\d{2}\/\d{2}\/\d{4})`

Regex test: [https://regex101.com/r/b7Ybg9](https://regex101.com/r/b7Ybg9)

## Important Info

- ⚠ **Global match** must be set to YES!

# Screenshot

 ![Screenshot_2024-02-02_190215](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/b/0/b091db93daba758327ec0188a4d8952f74f58917.png)

# Output

 ![Screenshot_2024-02-02_190221](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/9/4/940007ec7e7d599314770c9c35459e92bd010e12.png)

* * *

For more information, see [Text Parser](https://www.make.com/en/help/tools/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](https://en.wikipedia.org/wiki/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.
> 
> - The complete list of metacharacters can be found on the [MDN web docs website](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).
> - For a tutorial on how to create regular expressions, we recommend the [RegexOne website](https://regexone.com/).
> - For an easy, quick regex generator, try the [Regular Expressions generator](https://regex-generator.olafneumann.org/).
> - For experimenting with regular expressions, we recommend the [regular expressions 101 website](https://regex101.com/). Just make sure to tick the ECMAScript (JavaScript) FLAVOR in the left panel.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![samliew](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/samliew/32/13327_2.png) [@samliew](https://community.make.com/u/samliew)\
**Post date:** [February 2, 2024, 11:59am UTC](https://community.make.com/t/gmail-google-sheets-text-parser/26234/3 "2024-02-02T11:59:34Z")

</div>

Then, you can map each of the matched values in the columns in Google Sheets.

 ![Screenshot_2024-02-02_190253](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/1/6/16fdf2f83bc080ba9ae10c96a01a169b6135388c.png)

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

1. Copy the code below by clicking the copy button when you mouseover the **top-right** of the code block  
 ![Screenshot_2024-01-17_200117](https://europe1.discourse-cdn.com/flex013/uploads/make/original/3X/2/b/2b1b692880388420db5045bf51ef344e6698a816.png)

2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV to paste in the canvas.

3. Click on each imported module and save it. You may need to remap some variables.

### Modules JSON Export

```json
{
    "subflows": [
        {
            "flow": [
                {
                    "id": 34,
                    "module": "util:ComposeTransformer",
                    "version": 1,
                    "parameters": {},
                    "mapper": {
                        "value": "Invoice no.: 6089856/13/2024/F\nAmount to be paid:\n$424.45\npayment date\n13/02/2024\n\nInvoice no.: 7089856/13/2024/F\nAmount to be paid:\n$324.45\npayment date\n14/02/2024\n\nInvoice no.: 8089856/13/2024/F\nAmount to be paid:\nUSD 224.45\npayment date\n15/02/2024"
                    },
                    "metadata": {
                        "designer": {
                            "x": -294,
                            "y": -704
                        },
                        "restore": {},
                        "expect": [
                            {
                                "name": "value",
                                "type": "text",
                                "label": "Text"
                            }
                        ]
                    }
                },
                {
                    "id": 35,
                    "module": "regexp:Parser",
                    "version": 1,
                    "parameters": {
                        "pattern": "Invoice no\\.:\\s+(?<invoice>[^\\n]+)\\s+Amount to be paid:\\s+(?:\\$|USD\\s)(?<amount>\\d[\\d,]+(?:\\.\\d{2})?)\\s+payment date\\s+(?<date>\\d{2}\\/\\d{2}\\/\\d{4})",
                        "global": true,
                        "sensitive": true,
                        "multiline": false,
                        "singleline": false,
                        "continueWhenNoRes": false,
                        "ignoreInfiniteLoopsWhenGlobal": false
                    },
                    "mapper": {
                        "text": "{{34.value}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": -48,
                            "y": -702
                        },
                        "restore": {
                            "parameters": {
                                "multiline": {
                                    "collapsed": true
                                },
                                "singleline": {
                                    "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": "invoice",
                                "label": "invoice"
                            },
                            {
                                "type": "text",
                                "name": "amount",
                                "label": "amount"
                            },
                            {
                                "type": "text",
                                "name": "date",
                                "label": "date"
                            },
                            {
                                "type": "uinteger",
                                "name": "i",
                                "label": "i"
                            },
                            {
                                "type": "any",
                                "name": " __IMTMATCH__",
                                "label": "Fallback Match"
                            }
                        ]
                    }
                },
                {
                    "id": 37,
                    "module": "google-sheets:addRow",
                    "version": 2,
                    "metadata": {
                        "designer": {
                            "x": 196,
                            "y": -702
                        }
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

```

---

<div class="post-metadata">

**Author:** ![Exam\_Fox](https://avatars.discourse-cdn.com/v4/letter/e/b38774/32.png) [@Exam\_Fox](https://community.make.com/u/Exam_Fox)\
**Post date:** [February 5, 2024, 10:42am UTC](https://community.make.com/t/gmail-google-sheets-text-parser/26234/4 "2024-02-05T10:42:42Z")

</div>

Thank you, it works perfectly!

---

<div class="post-metadata">

**Author:** ![Make\_Bot](https://dub1.discourse-cdn.com/flex013/user_avatar/community.make.com/make_bot/32/14661_2.png) [@Make\_Bot](https://community.make.com/u/Make_Bot)\
**Post date:** [February 19, 2024, 11:02am UTC](https://community.make.com/t/gmail-google-sheets-text-parser/26234/5 "2024-02-19T11:02:00Z")

</div>


