Question

How do I filter out anything that includes a letter (and special characters)

  • 13 January 2022
  • 2 replies
  • 708 views

Hi there everyone!

 

I can’t figure this out for the life of me. How would one go about adding a filter that doesn’t allow any data with letters/words (and bonus for special characters) to pass?

 

For context, the form feeding this collects phone numbers and I want to make sure not to pass data that includes letters in it.

 

Note if you have a solution that includes filtering out special characters, we would have to make the exception for “+” because of the country codes.

 

Example:

  • Data from form is: "+1-123-443e"

  • Zapier filters catches this because "e" is in it

 

Appreciate any help, thanks!


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +14

Hi @magicmiles 

Try this Javascript Code step which will search for non-numeric characters excluding +, then follow it with a Filter step.

Code: https://zapier.com/apps/code/help

Filter: https://zapier.com/apps/filter/help

 

CONFIG

 

RESULTS

 

CODE

let IN = inputData.IN;
let OUT = IN.match(/[^0-9+]/g);
let MATCH = false;
if (OUT != null) {
MATCH = true;
}

output = [{IN, OUT, MATCH}];

 

@Troy Tessalone thanks for the help! I will give it a try and let you know how it goes.