Split text in single line into multiple parts

Hi Makers!

I’ve split the Text Content from a mailhook into new lines as seen below:

Purechat Text Content Split Screenshot

I would like to further split the contents in lines 4 and 5 into separate parts like this:
Your Name: Name
Your Email: mail@email.com
Number: 1234567890
Project Name: Test Project Name

How can I achieve this?

Are you very certain that the text you want to split will always be in the array index 4 and 5?

If not, you might want to “merge” all of the text into a single variable before we can use the Text Parser “Match Pattern” module.

If you need further assistance, please provide the following:

Please provide the input and output bundles of the modules by running the scenario (or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.
Screenshot_2023-10-06_141025

A.

Save each bundle contents in your text editor as a bundle.txt file, and upload it here into this discussion thread.

Uploading them here will look like this:

module-1-input-bundle.txt (12.3 KB)
module-1-output-bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted bundles in this manner:

  • Either add three backticks ``` before and after the code, like this:

    ```
    input/output bundle content goes here
    ```

  • Or use the format code button in the editor:
    Screenshot_2023-10-02_191027

Providing the input/output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

This will allow others to better assist you. Thanks!

samliewrequest private consultation

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

1 Like

This is not correct, the example value you used have the semi-colons in the wrong locations.

Do compare it to the sample data provided by the author to see the mistake.

samliewrequest private consultation

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

1 Like

Hi samliew,

Thanks for the detailed response!

Are you very certain that the text you want to split will always be in the array index 4 and 5?

Yes, the text I want to split will always be in index 4 and 5.

Please provide the input and output bundles of the modules by running the scenario
(or get from the scenario History tab), then click the white speech bubble on the top-right of each module and select “Download input/output bundles”.

Here are input & output bundles for a test run. Arrays index 4 and 5 will always contain the text I have to split.

line_split_module_input.txt (1.4 KB)
line_split_module_output.txt (1.3 KB)

Welcome to the Make community!

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

Your Name: (?.+) Date: (?.+) Your Email: (?.+) Your Number: (?.+) Your Requirement: (?.+) Website:

and this input:

{{join(slice(183.`first-text-content`; 3; 5); space)}}

Proof

https://regex101.com/r/Sct4Jv

Important Info

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

Screenshot

Output

Screenshot_2024-06-25_180638


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!

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
    Screenshot_2024-01-17_200117

  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.

View Module Export Code

JSON

{
    "subflows": [
        {
            "flow": [
                {
                    "id": 185,
                    "module": "regexp:Parser",
                    "version": 1,
                    "parameters": {
                        "pattern": "Your Name: (?<name>.+) Date: (?<date>.+) Your Email: (?<email>.+) Your Number: (?<number>.+) Your Requirement: (?<requirement>.+) Website:",
                        "global": false,
                        "sensitive": true,
                        "multiline": false,
                        "singleline": false,
                        "continueWhenNoRes": false
                    },
                    "mapper": {
                        "text": "{{join(slice(183.`first-text-content`; 3; 5); space)}}"
                    },
                    "metadata": {
                        "designer": {
                            "x": -2077,
                            "y": -2069,
                            "messages": [
                                {
                                    "category": "last",
                                    "severity": "warning",
                                    "message": "A transformer should not be the last module in the route."
                                }
                            ]
                        },
                        "restore": {},
                        "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
                            }
                        ],
                        "expect": [
                            {
                                "name": "text",
                                "type": "text",
                                "label": "Text"
                            }
                        ],
                        "interface": [
                            {
                                "type": "text",
                                "name": "name",
                                "label": "name"
                            },
                            {
                                "type": "text",
                                "name": "date",
                                "label": "date"
                            },
                            {
                                "type": "text",
                                "name": "email",
                                "label": "email"
                            },
                            {
                                "type": "text",
                                "name": "number",
                                "label": "number"
                            },
                            {
                                "type": "text",
                                "name": "requirement",
                                "label": "requirement"
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "metadata": {
        "version": 1
    }
}

samliewrequest private consultation

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

3 Likes

This worked like a charm! Thank you so much for taking the time to help me out, samliew.

I’m not really good with RegEx and would just like to ask you about the regex below

Your Name: (?<name>.+) Date: (?<date>.+) Your Email: (?<email>.+) Your Number: (?<number>.+) Your Requirement: (?<requirement>.+) Website:

What is the point of grouping parts of the text into <name>, <date> and so on?

1 Like

To find out why, try it without the groups :slight_smile:

Your Name: (.+) Date: (.+) Your Email: (.+) Your Number: (.+) Your Requirement: (.+) Website:

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!

samliewrequest private consultation

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

1 Like

Hi again samliew,

So here’s an update after I let the scenario run and observed for the past week.

Turns out, you were right in being skeptical about this :sweat_smile: :

Are you very certain that the text you want to split will always be in the array index 4 and 5?

There are few instances where text being entered by users overruns the line limit for the line split and its placed into the next line. And that messes up the whole flow.

Here are input & output logs of a Set Variable module that’s splitting text received from mailhook by newline in a failing case:

input-module-failing-case.txt (1.7 KB)
output-module-failing-case.txt (1.6 KB)

first-text-content Array
1	Pure Chat
2	[https://app.purechat.com/content/images/logos/purechat-teal-small.png]
3	https://app.purechat.com Missed Chat
4	Your Name: Tester Date: 1/7/2024 Your Email: Tester1@yahoo.co.in Your
5	Number: 1234567890 Your Requirement: Extra detailed requirement mentioned
6	comes here Website:
7	https://www.domain.com/page-post-name/
8	[https://www.domain.com/page-post-name/]
9	Source: https://www.google.com/ [https://www.google.com/] Operator: - Tags: -
10	Tester 17:11
11	joined the chat
12	Tester 17:11
13	Extra detailed requirement mentioned comes here
14	This chat was closed because the visitor left the page or lost internet
15	connectivity.
16	Thanks for using Pure Chat!
17	Details:
18	Date: 1/7/2024
19	Operator: No operator
20	Website: https://www.domain.com/page-post-name/
21	Source: https://www.google.com/
22	IP Address: 192.168.1.1
23	Rating: No Rating
24	Feedback:
25	Your Number: 1234567890
26	Your Requirement: Extra detailed requirement mentioned comes here
27	Your Email: Tester1@yahoo.co.in
28	Tags:
29	[1/7/2024 - 17:11] Tester joined the chat
30	[1/7/2024 - 17:11] Tester said:
31	Extra detailed requirement mentioned comes here

For comparison, Here are the input and output modules from the previous case we first looked at in the thread above:

line_split_module_input.txt (1.4 KB)
line_split_module_output.txt (1.3 KB)

Sometimes the Your Requirement text is long and overruns into the next line and that’s causing the scenario to not run as expected.

If I can remove all the lines in the array from 1 to 17 and then work with the content after line 17 in any instance, that would solve the issue probably.

Any advice on how I can tackle this?

I think it’s best if you’d create a new thread for this, because you might need a different way of doing it (and the regex pattern will definitely be different).

While it’s tempting to continue an existing thread, a more effective approach would be to start a new topic. It helps other community users to respond to your query, and keeps our space organised for everyone. If you start a new conversation you are also more likely to get help from other users. You can refer others back to a related topic by including that link in your question. Thank you for understanding and keeping our community neat and tidy.

The “New Topic” link can be found in the top-right of the header:

samliewrequest private consultation

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

1 Like

Makes total sense. Thanks @samliew

I’ve created a separate thread for this off-shoot issue here: Split / Slice text content and retrieve only Select rows

Thanks for all the help!