jQuery in Action, 3rd edition
The moose likes Struts and the fly likes Regular Expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Regular Expression" Watch "Regular Expression" New topic

Regular Expression

Ashish Bassi

Joined: Aug 22, 2007
Posts: 11
I need to create a regular expression to check if the password contains
- atleast 1 Capital letter
- atleast 1 Special character
- atleast 1 numeric
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.
arulk pillai
Ranch Hand

Joined: May 31, 2007
Posts: 3359
Try the following and test it thoroughly:

look at http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html for explanation.
[ August 22, 2007: Message edited by: arulk pillai ]

[Java-Success.com] | [Java job hunting know how] | [Java resumes]
Alan Moore
Ranch Hand

Joined: May 06, 2004
Posts: 262
Ashish Bassi

Joined: Aug 22, 2007
Posts: 11
Thank, i tried it, it works in a stand alone java program, not in struts though, inspite of removing the "\" symbol
prakash chandra

Joined: Aug 14, 2007
Posts: 24
Following is the simple code which will fulfill your requirements. It depends on what special character you want in the Password. You can just append the special character you want in static variable SPECIAL of following code.

[ August 22, 2007: Message edited by: prakash chandra ]

SCJP 6.0
Bhaskar Reddy
Ranch Hand

Joined: Dec 17, 2002
Posts: 52
Have a look at RegEx Library.

For your specific req, you may have to search in that, or learn it and build it as per your requirement...
I agree. Here's the link: http://aspose.com/file-tools
subject: Regular Expression
jQuery in Action, 3rd edition