cancel
Showing results for 
Search instead for 
Did you mean: 

is there a trick to testing a text field for characters like * & @

johnw
Executive Chef I
Executive Chef I

our ERP will allow a user to enter a serial number like 1234*

is there a way to test of an * or & or @ etc is in a text field so i can send an email to a user to fix rather than move the incorrect data to SFDC

 

thanks

1 ACCEPTED SOLUTION

gary1
Executive Chef III
Executive Chef III

You can do this with match or scan, and regex (regular expressions).

Regex is a little complicated to learn IMO, but it is an essential tool for problems like this.

Here is a quick formula that will test for any characters that are not a-z, A-Z, and 0-9. It will return true or false based on the input.

input = "abc@123*"
[input].match?(/[^a-zA-Z\d]/)
## output >> true

You can also use scan to return an array of non-matching characters:

[input].scan(/[^a-zA-Z\d]/)
## output >> ["@", "*"]

 

 

View solution in original post

1 REPLY 1

gary1
Executive Chef III
Executive Chef III

You can do this with match or scan, and regex (regular expressions).

Regex is a little complicated to learn IMO, but it is an essential tool for problems like this.

Here is a quick formula that will test for any characters that are not a-z, A-Z, and 0-9. It will return true or false based on the input.

input = "abc@123*"
[input].match?(/[^a-zA-Z\d]/)
## output >> true

You can also use scan to return an array of non-matching characters:

[input].scan(/[^a-zA-Z\d]/)
## output >> ["@", "*"]