Formula to determine if a string contains numbers

Hey everyone,

Would it be possible to create a formula that determines if a string contains numbers or not? For example "abc123" would trigger true whereas "abcdef" would trigger false.

Thanks in advance!

Hi @louis.goode,

Welcome to the forum :slightly_smiling_face:
Yes, it is possible to check for the presence of a digit/s in a string using the testregex function.

{formtext: name=string; default=abc123}
{if: testregex(string, "\d")}number is present{else}number is not present{endif}

2 Likes

Hi! This is an old thread but I wanted to see if there is a way to exclude certain numbers? Like only if the number is greater than 0

Hi @Nathan_Manning,

You can use extractregex function to get the exact number and compare it with 0 as in the snippet below:

{formtext: name=string; default=abc123}
{if: testregex(string, "\d+") and extractregex(string, "\d+") > 0}A number greater than zero is present{else}No number is present or the number is zero{endif}

1 Like