how to regex the 'metacharacters'

i want to write a pattern for password field that users must use metachars for them passwords (metacharacters like :!@#$%^&*() ), i search about it but didnt find any pattern , is this possible to write such pattern ? Thanks in Advance


If you are looking for a regexp that will match all special characters, you have a few ways you could go:

  1. You could write a regexp that excludes alphanumerics:


  2. You could select the special characters that you are interested in and, carefully escaping the ones that have special meaning in regexps with a backslash, write your own regexp for that specific set of characters.

  3. If you know what charset will be involved and if it's reasonably small (so not UTF-8, which will be huge), you can go through it and identify the special chars and then do #2 above. This might be feasible if you are 100% certain that all data will come in as (for example) ASCII chars.

If you mean that the password must contain at least one of those characters, then something like this might work:

if (!preg_match('/['.preg_quote('!@#$%^&*()').']/', $password)) {
    // fails

Yes. You can put most of them into your regular expression like any other character. For those having a special meaning in regular expressions, prefix them with \ or \\ depending on your programming language.

Need Your Help

Union two List

c# gridview rowcommand

i want to union, merge in a List that contains both references, so this is my code, how can i define a list ready for this porpouses ?

Access to lisf of model object by EL in javascript

javascript jsp spring-mvc jstl el

In my application I want to obtain the data of the model object that was set in the session from controller by using select box in jsp.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.