How to check if an input value contains numbers
In Aperture Data Studio, in order to check if an input value contains numbers, you can use the Matches Expression function.
The Matches Expression function uses a regular expression to specify a pattern to be matched against. If you are not familiar with a regular expression, it may take some exploration to get to the results you want. Aperture Data Studio supports the java based regex, so you may want to use a website like the regex101.com to test your regex (Select the Java 8 Flavor).
When using Matches Expression to check for numbers, do note that you need to consider the entire input value, and where the numbers would likely appear within the input value - whether it is at the beginning/end/anywhere within the input value.
Example 1: When you use a regex of [0-9], you are only matching a single character in the range of 0-9, so as long as your input value contains more than a single (any) character, the result will be false.
Example 2: When you use a regex of .*[0-9].*, you are allowing a single character in the range of 0-9 to be found within an input value that may contain any other leading/trailing characters.
Can you think of a better way to check if an input value contains numbers? Feel free to share your ideas here.
Comments
-
Great, that works for me. As does .*\d.*
2