Testing for special characters \ / : * ? " < > |

In delphi, I have an edit box and I need to test each character to make sure its not one of the following: \ / : * ? " < > | and if it is, it needs to be removed. How can I find out if one of the symobls are entered. I know I can test them on key presses but I dont know what to compare them to.
Who is Participating?
bokistConnect With a Mentor Commented:
Try onKeyPress event,  something like this

  if  Key in ['\', '/', ':', '*', '?', '"', '<', '>', '|']  then Key := #0;
MerijnBSr. Software EngineerCommented:
do you want to filter then, so the user can't insert them in the first place, or do you want to remove them afterwards?
MerijnBConnect With a Mentor Sr. Software EngineerCommented:
that would be

  if  (Key in ['\', '/', ':', '*', '?', '"', '<', '>', '|'])  then Key := #0;
ding-dongAuthor Commented:
Either would be acceptable, would be better not allowing them to be entered in the first place.
ding-dongAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.