LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 02-15-2012, 06:37 AM   #1
bradvan
Member
 
Registered: Mar 2009
Posts: 101

Rep: Reputation: 16
regex help


I'm working on a project that needs to write some java code to check supplied passwords against corporate standards. I'm the system administrator, but they've asked me for some regular expression help. First, the rules:
  1. be at least 14 characters in length
  2. consist of a mix of all four character sets - upper case, lower case, numeric, and special characters
  3. contain no more than three consecutive characters from any one of the four classes

The regular expression I've come up with is:
Code:
((?=.*\d{1,3}?)(?=.*[a-z]{1,3}?)(?=.*[A-Z]{1,3})(?=.*[:punct:]{1,3}?).{14,})
It's failing on the last requirement. If anyone has some suggestions, I'd love to hear them.

Regards,

Brad

Last edited by bradvan; 02-15-2012 at 09:56 AM. Reason: typo in regex. Thanks Sag47!
 
Old 02-15-2012, 07:30 AM   #2
sag47
Member
 
Registered: Sep 2009
Location: Philly, PA
Distribution: Kubuntu x64, RHEL, Fedora Core, FreeBSD, Windows x64
Posts: 687
Blog Entries: 21

Rep: Reputation: 133Reputation: 133
Perhaps,
Code:
((?=.*\d{1,3}?)(?=.*[a-z]{1,3}?)(?=.*[A-Z]{1,3})(?=.*[:punct:]{1,3}?).{14,})
You had a hyphen instead of a comma.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] differences between shell regex and php regex and perl regex and javascript and mysql golden_boy615 Linux - General 2 04-19-2011 01:10 AM
Perl to find regex and print following 5 lines after regex casperdaghost Linux - Newbie 3 08-29-2010 08:08 PM
Help with regex tbeehler Linux - Software 4 07-11-2008 10:05 AM
regex with sed to process file, need help on regex dwynter Linux - Newbie 5 08-31-2007 05:10 AM
Need a regex, I suck at regex's d3funct Programming 4 02-25-2002 08:28 PM


All times are GMT -5. The time now is 05:11 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration