javascript - Regular expression to validate set of special characters - Stack Overflow

Would anybody please help generate a regular expression to be validated using javascript ?This regular

Would anybody please help generate a regular expression to be validated using javascript ? This regular expression should validate alphanumerical values in addition to the following set of characters:

{. - / \ ( ),'}_ + : ? ® © T

Thanks and best regards..

Would anybody please help generate a regular expression to be validated using javascript ? This regular expression should validate alphanumerical values in addition to the following set of characters:

{. - / \ ( ),'}_ + : ? ® © T

Thanks and best regards..

Share Improve this question edited Jul 3, 2013 at 1:08 Alan Moore 75.3k13 gold badges107 silver badges161 bronze badges asked Jul 1, 2013 at 20:50 Mostafa MoatassemMostafa Moatassem 3513 gold badges11 silver badges23 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Sounds like you want a pattern like this:

^[\w{./\\(),'}+:?®©-]+$

Important things to note:

  • ^ and $ match the start and end of the string, respectively, meaning that only these characters are allowed.
  • [ and ] define a character class, which matches any of the characters defined inside the brackets
  • \w matches any alphanumeric character or underscore.
  • I omitted T and _ from the character class they are allowed by \w.
  • \\ is needed to escape the backslash, because that's a special character in regular expressions.
  • - must e at the beginning or end of the character class or else be escaped. Otherwise, it would mean something like a-z any characters between a and z.
  • Many other characters here have special meaning within regular expressions (e.g. ?, +, and ()), but it's not necessary to escape them within a character class.
  • The + on the end means that one or more of these characters is allowed.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742295777a4417086.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信