Subscribe Bookmark RSS Feed

how to use jsl to test if a string contains only A~Z and 0~9?

robust1972

Community Trekker

Joined:

Jan 15, 2014

how to use jsl to test if a string contains only A~Z and 0~9?

my data shall  contains only A~Z and 0~9 but when 1 or few bit flip then there is not printable characters.

many thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

You can use regular expressions to check this.  Create a new column that contains the following formula:

If (Regex(:Name("2nd"), "^[a-zA-Z0-9]+$") == :Name("2nd"), "Yes", "No")


The new column will have the value "Yes" if it is purely alphanumeric, "No" otherwise.

3 REPLIES
Solution

You can use regular expressions to check this.  Create a new column that contains the following formula:

If (Regex(:Name("2nd"), "^[a-zA-Z0-9]+$") == :Name("2nd"), "Yes", "No")


The new column will have the value "Yes" if it is purely alphanumeric, "No" otherwise.

robust1972

Community Trekker

Joined:

Jan 15, 2014

thanks for your reply, PMroz.

What ^ and +$ for?

how can I make it return 1 or 0 so that I could use it together with other comparison algorithm?

pmroz

Super User

Joined:

Jun 23, 2011

The ^ means the start of the string, the + means to match at least one character, and the $ means the end of the string.

To return a 1 or 0 simply change Yes to 1 and No to 0:

If (Regex(:Name("2nd"), "^[a-zA-Z0-9]+$") == :Name("2nd"), 1, 0)

There are a ton of websites out there that explain regular expressions btw.