BookmarkSubscribe
Choose Language Hide Translation Bar
Community Trekker

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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

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

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 3
Super User

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

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.

Community Trekker

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

What ^ and +\$ for?

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

Super User

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

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.