Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Regex to filter alphanumeric combinations

dougejm
5 - Atom

Hi,

 

I am looking to filter out items not matching the requirements. I'm looking to keep items containing letters, numbers and special characters, it can be different combinations and I am struggling to get on regex code to match them all (or a simpler way to do it). If any help, each item will always be 3 characters or more.

 

Example what to keep/filter out:

abc123 (Letters and Numbers in any order = KEEP)

123456 (All numbers = KEEP)

abc-123 (Letters, special character, number in any order, length and any special character = KEEP)

abcdef (All Letters = OUT)

abc-efd (All letters and special characters in any order = OUT)

 

Hope this makes sense and thank you in advance

5 REPLIES 5
DataNath
17 - Castor

@dougejm I'm a little confused by the logic here. In your explanation you say 'filter out items containing letters, numbers and special characters', but in example 3, this is exactly that and you say it should be kept? From your examples, it looks like you want to filter anything where there aren't any numbers present - is that right? If that's the case then you can use a filter like so which just checks whether there's 1 (or more) occurrence of a digit:

 

REGEX_CountMatches([Input], '\d') > 0

 

DataNath_0-1664787859499.png

 

dougejm
5 - Atom

Hi yes, apologies I'm using different/wrong wording. In the text I meant filter out as keep as in filtering through the filter and be kept. Sorry that is very confusing of me. Trying to find a way to change the text/question but not able to find it.

The example is the right way what to keep/not to keep.

DataNath
17 - Castor

No problem @dougejm. I made an edit to my post which might've been as you were replying - would that filter handle your request or are some records still getting through that you need removing?

dougejm
5 - Atom

Worked like a charm, thank you! I have marked it as the solution

gotu
7 - Meteor

Hi,
Can someone help me to build the regex to filter out non alphabets and non numbers as well special characters?

 

So here is the rule : According to the rule, it means you can have numbers and/or alphabets. You can't have anything else. Nulls can be ignored here

 

1234 - Keep

ab123 - keep

abcd - keep

 

anything which doesn't have these combination should be filtered out using the regex

Labels