Please help me extract highest number from a string

What is the easiest way to extract highest number from a string using make.com?

  • I have very loose input strings such as: “20”, “25-30”, “30 –35”, “40 až 50”, “70 maybe 50”.
  • I need to extract a single number, the highest one, as integer.

In javascript it would be something like this:

function findLargestNumber(inputString) {
    const regex = /\d+/g;
    let maxNumber = null;
    let match;

    while ((match = regex.exec(inputString)) !== null) {
        const currentNumber = parseInt(match[0], 10);
        if (maxNumber === null || currentNumber > maxNumber) {
            maxNumber = currentNumber; 
        }
    }
    return maxNumber;
}

What is the easiest most straightforward way to do this with make.com? Custom JS module is some weird 3rd party and I do not know how to handle Text Parser so that it does What I want. I’ve been stuck with this for way too long, please nudge me to the right direction. Thank you!

Welcome to the Make community!

How do your input bundle look like?

if you convert everything to a single string, you can also regex the matches using the Text Parser Match Pattern module, then use the built-in function max.

For further assistance, please provide the following:

1. Screenshots of module fields and filters

Please share screenshots of relevant module fields and filters in question? It would really help other community members to see what you’re looking at.

You can upload images here using the Upload icon in the text editor:
Screenshot_2023-10-07_111039

2. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

3. And most importantly, Output bundles

Please provide the output bundles of the modules by running the scenario, then click the white speech bubble on the top-right of each module and select “Download output bundles”.
Screenshot_2023-10-06_141025

A.

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

Uploading it here will look like this:

bundle.txt (12.3 KB)

B.

If you are unable to upload files on this forum, alternatively you can paste the formatted output bundle 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 output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

samliewrequest private consultation

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

1 Like

This is what the input looks like, it is a simple string value coming from a webhook:

Sadly, I can’t share the blueprint because it contains sensitive data.

This is the output of Text Parser, can this be used as input for the max function?

Problem is all the steps after text parser are performed twice so the max function likely needs a different approach.

I believe it should be as simple as this then.

Output

Screenshot_2024-06-13_180655

Every result (item/record) from a search/match module will output a bundle. To “combine” them into a single structure, you’ll need to use an aggregator of some sort.

Aggregators are modules that accumulate multiple bundles into one single bundle. An example of a commonly-used aggregator module is the Array aggregator module. The next popular aggregator is the Text Aggregator which is very flexible and has applies to many use-cases.

There are other types of aggregator modules, click the below links to find out more:

samliewrequest private consultation

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

4 Likes