Unsure about the use of backslash here.

Posted on 2014-08-25
Last Modified: 2014-08-25
Do I have to use a back slash \ for ( and ) or these < > below?


Open in new window

Question by:kadin
    LVL 82

    Expert Comment

    by:Dave Baldwin
    Here's the page for PHP PCRE (Perl Compatible Regular Expressions):

    Author Comment

    I have two books I can refer to. I can take the time to do research but the reason I ask is I don't have the time. Expert Exchange costs me money - the point of which is to save me time.
    LVL 35

    Accepted Solution

    No, you don't have to use the backslash for those characters. This is because most of the characters that are "special" in a regex lose there "specialness" when inside a character set (ie. inside the square brackets [  ]  ).  Note though that the backslash IS used for the square brackets though, because otherwise the regex engine wouldn't know if you wanted to match a closing square bracket  ]  or if that was just the end of the character set.

    Refer to this for detailed info...

    Author Closing Comment

    Thanks for your help. Also I found this:
    LVL 35

    Expert Comment

    Thanks for your help
    You're welcome!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Whatever be the reason, if you are working on web development side,  you will need day-today validation codes like email validation, date validation , IP address validation, phone validation on any of the edit page or say at the time of registration…
    As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
    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