Alteryx Designer Desktop Discussions

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

Using Regex_Match in Interface Error Message Tool

jamesdrab
6 - Meteoroid

I have a question in my app that requires the user to enter a name.  The name should consist of only lower-case letters, numbers or an underscore between words.  I am trying to use the Regex_Match function in the Error Message tool to warn the user when the name contains characters that are not lower-case letters, numbers or underscores.  Right now I have this:

 

Regex_Match([#1], '[^a-z0-9_]')

 

but it isn't working.  

 

Also, what is the iCase parameter within the Regex_Match function?

 

Thanks

3 REPLIES 3
Thableaus
17 - Castor
17 - Castor

Hi @jamesdrab 

 

The default is ignore the Case Sensitivity.


To add case sensitivity you need to add a 0 at the end of the expression.

 

Something like Regex_Match([#1], '[^a-z0-9_]', 0)

 

But that shouldn't be what you're looking for.

 

You should actually look for something like this

 

!Regex_Match([#1], '[a-z0-9_]+', 0)

 

The exclamation sign before is something like "NOT". So, if something doesn't match your pattern, it should error out.

 

Cheers,

jamesdrab
6 - Meteoroid

Thank, that worked.  I thought that the '^' inside the brackets usually means 'Not' in regex, is there a reason it doesn't work in this case?

Thableaus
17 - Castor
17 - Castor

@jamesdrab 

 

The thing is that the REGEX_MATCH function sees the string as whole.

 

So, for the expression to be true, all characters in your pattern must match.

 

First of all, your expression was just looking at a single character. It didn't have any quantifier like + or * to add multiple occurences of that pattern.

 

Something like this - 

Regex_Match([#1], '[^a-z0-9_]+')

wouldn't work because it would look for an expression made JUST by non lowercased characters, non-numbers and underscores.

 

This for example -  aaaAbbb999 -  wouldn't be captured as an error, cause it has lowercased characters and numbers, despite having a single uppercased character.

 

Cheers,

Labels