File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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: 42965
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: 3371
Try the following and test it thoroughly:

look at for explanation.
[ August 22, 2007: Message edited by: arulk pillai ]

[] | [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:
subject: Regular Expression
It's not a secret anymore!