Regular expression & arrayContains

Solved!
OlivierAb
Level 3
Regular expression & arrayContains

Hello,

I want to check if a variable contains a letter. For this I want to use a formula in a prepare recipe

Here my code :

if(arrayContains([A-Z], strval('name_var')),1,2)

Output is always '2' even when there is a letter in the variable i'm checking

Thank you, Olivier

0 Kudos
1 Solution
Ignacio_Toledo

You are right, I forgot the '.*' at the end of the expression.

Happy to help and have a great week! Ignacio

View solution in original post

0 Kudos
3 Replies
Ignacio_Toledo

Hi @OlivierAb 

My impression from the documentation is that arrayContains doesn't work with regular expressions, which is what you are trying to do apparently.

What might work is this:

if(arrayLen(match(column, ".*([A-Za-z])")) > 0, 1, 2)

where you should replace column with the name of your column of interest.

If I understood your problem wrongly please let me know! Cheers

0 Kudos
OlivierAb
Level 3
Author

Thanks a lot Ignacio !

it works with just a little adjustment. Indeed, ".*" is missing

the final working formula is "if(arrayLen(match(column, ".*([A-Za-z]).*")) > 0, 1, 2)"

Thanks again for your reactivity, Olivier

Ignacio_Toledo

You are right, I forgot the '.*' at the end of the expression.

Happy to help and have a great week! Ignacio

0 Kudos