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

Posted on 2007-10-10
Last Modified: 2009-07-27
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.
Question by:ding-dong
    LVL 19

    Expert Comment

    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?
    LVL 6

    Accepted Solution

    Try onKeyPress event,  something like this

      if  Key in ['\', '/', ':', '*', '?', '"', '<', '>', '|']  then Key := #0;
    LVL 19

    Assisted Solution

    that would be

      if  (Key in ['\', '/', ':', '*', '?', '"', '<', '>', '|'])  then Key := #0;

    Author Comment

    Either would be acceptable, would be better not allowing them to be entered in the first place.

    Author Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now