Analyzing Text for Special Characters in a Conditional Formula

Danielle Arteaga
Danielle Arteaga ✭✭✭✭✭✭
edited 11/09/21 in Formulas and Functions

I have two sheets. Sheet 1 (Character Table) has a list of non-alphanumeric text symbols (e.g., !, @, #, $, etc.) and alphanumeric characters (A-Z, a-z and 0-9) alongside their ASCII values. This table distinguishes the non-alphanumeric values from the alphanumeric ones by classifying their types as "Special" or "Alphanumeric."

I have a second table, which contains values that will be entered by users via a form. The values will eventually become user IDs, so they must be AT LEAST 3 characters but NOT MORE THAN 8 characters and CANNOT contains any "Special" character type.

Right now, I have a painfully complex IF statement that looks like this:

=IF(OR(OR(CONTAINS("!", [Choice 2]@row), CONTAINS("@", [Choice 2]@row), CONTAINS("#", [Choice 2]@row), CONTAINS("$", [Choice 2]@row), CONTAINS("%", [Choice 2]@row), CONTAINS("^", [Choice 2]@row), CONTAINS("&", [Choice 2]@row), CONTAINS("*", [Choice 2]@row), CONTAINS("+", [Choice 2]@row), CONTAINS("-", [Choice 2]@row), CONTAINS("_", [Choice 2]@row), CONTAINS("~", [Choice 2]@row)), OR(LEN([Choice 2]@row) < 3, LEN([Choice 2]@row) > 8)), 1, 0)

It works, but it's missing a bunch of special characters, because I can't properly write a formula that recognizes those as text instead of the function they perform. (For example, the ditto mark and the equal sign)

So, I was hoping to be able to write a formula that would reference the Characters table to determine whether the value entered in Choice 2 contains any character for the type Special on the Character Table as well as whether it is the required length.

I feel like it might be some combination of JOIN/COLLECT/CONTAINS, but I can't figure it out. Might be making this overly complex ...?

Best Answer

Answers

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!