Filter a string of text for certain values?

Does Make offers some sort of a “string filtering” function where I can pass it a string of text, and it returns to me only the values that I want to retrieve from that string of text?

For example, I may only want to retrieve the numbers from a random string of text.

So, if I get a random string of text that looks like this: “SK4H67KI123F”, I only want to pull the numbers out of it, so my end result would look like this: 467123

I cannot predict in advance how many characters or numbers will be in the string of text, and I do not know the placement of those numbers. But I just want to extract all the numbers from the string of text.

I used to be a FileMaker developer, and FileMaker offered a very simple “filter” function. You could give FileMaker a string of text, and then you could tell it to only return to you the values that you specified.

So you could tell FileMaker to return just numbers, just certain characters, just certain symbols, whatever you wanted to extract from the string of text.

Are there any functions to do something like that in Make?

Thank you!
Scott

Welcome to the Make community!

You can use the built-in function replace to remove the inverse of what you want to retain. This method won’t cost a single operation.

e.g.: for your example above,

{{ replace(1.string; "/\D+/g"; emptystring) }}

For more information, see the function documentation in the Help Center and do the tutorials in the Make Academy.

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.

4 Likes

Thanks so much, @samliew! :grinning_face:

I didn’t realize that the replace function could use REGEX expressions. That’s a gigantic help and a big breakthrough!

Like you said above, if I can figure out the proper REGEX expression for each one of my needs, then I can use the replace function to replace invalid characters instead of trying to keep valid characters.

Ideally, I would love to have a REGEX expression that finds all letters & symbols. Would you know how to write that REGEX expression? If not, I will try to figure it out with ChatGPT!

Thanks so much for your help!

1 Like

No problem, really glad I could help!

You need to define the format before you can create an expression for it.

Alternatively, I have provided examples of how to do/use this function & regular expressions elsewhere on the forum if you want to go down this route. I think it’s in one of the threads I replied to previously. View my profile (or use the search feature on my profile) to find this topic.

If you need further assistance, please use the Hire a Pro category, where you can receive private 1-to-1 assistance via video call/screenshare/private messaging/etc. This may help you get your issue resolved faster especially if it is urgent, or contain sensitive information. It is important to post your request in the Hire a Pro category, as forum members are not allowed to advertise their services in other categories like here (even if it’s free/unpaid). Once you have posted in the Hire a Pro category, that will allow other members to assist you over other forms of communication.

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!

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.