[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Unsure about the use of backslash here.

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

/^[a-zA-Z0-9#$%^&=\[\]()<>\/_-]{8-16}$/

Open in new window

0
Comment
Question by:kadin
  • 2
  • 2
5 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 40284458
Here's the page for PHP PCRE (Perl Compatible Regular Expressions): http://us1.php.net/manual/en/book.pcre.php
0
 

Author Comment

by:kadin
ID: 40284482
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.
0
 
LVL 36

Accepted Solution

by:
mccarl earned 2000 total points
ID: 40284492
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... http://www.regular-expressions.info/charclass.html#special
0
 

Author Closing Comment

by:kadin
ID: 40284545
Thanks for your help. Also I found this:
stackoverflow.com/questions/399078/what-special-characters-must-be-escaped-in-regular-expressions
0
 
LVL 36

Expert Comment

by:mccarl
ID: 40284546
Thanks for your help
You're welcome!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
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…
Suggested Courses

834 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