(Regex) how do I invalidate a string if it contains a certain character?

Posted on 2009-02-23
Last Modified: 2012-05-06
Hi, I am trying to do the following with regular expressions.
I want every string to match unless it contains the characters ( ) or "
i tried
but the string "hello (world)" was still a valid match.
I also tried
which still matched "hello (world)"

some help? what am I not understanding here?
Question by:colonel720
    LVL 10

    Accepted Solution

    That should do: [^()"]*
    LVL 10

    Expert Comment

    With the part (.*)? you will always match anything, it means: any character, any times (inner part), 0 or 1 time (outer part)
    LVL 1

    Author Closing Comment

    I actually tried that, and it was partially matching "hello (world)".. I am using an evaluator that returns a bool if the string matches or not. it worked when i anchored it like \A[^()"]\z
    LVL 10

    Expert Comment

    Yes you're right I forgot the anchors.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    761 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

    8 Experts available now in Live!

    Get 1:1 Help Now