I’m trying to remove strings with unrecognized characters from string collection. What is the best way to accomplish this?
I’m trying to remove strings with unrecognized characters from string collection. What is the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To remove strings that contain any characters you don’t recognize:
(EG: if you want to accept lowercase letters, then “foo@bar” would be rejected”)
^[A-Z]$Note: This won’t work for strings that contain newlines, but you can tweak it if you need to support that
To remove strings that contain entirely characters you don’t recognize:
(EG: If you want to accept lowercase letters, then “foo@bar” would be accepted because it does contain at least one lowercase letter)
^character inside the square brackets, and starts with ^ and ends with $. For example, if your “recognized” characters are uppercase A through Z, it would be^[^A-Z]$