This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

RegularExpression in Java  RSS feed

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Below is my code.



if i make individual patterns then output is coming properly.

but i want to get same output with one of below pattern.



but both are not working with min max length condition of the string. please let me know where i am doing wrong.

Thanks
Peter


[HENRY: Added Code Tags]
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code. It will highlight your code and make it much easier to read. It probably will also increase the number of people helping you. Also use proper indentation. This is hard to read. You can edit your post with the button.
 
author
Sheriff
Posts: 23568
138
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

James Peter wrote:
but both are not working with min max length condition of the string. please let me know where i am doing wrong.



How are you using the expression? Are you using the find() method? Or the matches() method?

With the second password pattern, the matches() method should work (or at least, by eyeballing it, I didn't actually try it out).

Henry
 
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) You haven't included '&' in your set of 'special' characters!
2) You need to use matches() and not find() or the length check term will pass for lengths greater than 7.

P.S. What business case can be made for limiting a password to less than 8 characters? Seems daft to me as presumably one is only storing a seeded digest and not the full password and it reduces significantly the entropy of the allowable passwords.
 
James Peter
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Henry,

Thanks for adding code tag. I was about to do that.

Hi James,

thanks for your comment. I forgot to add "&" character in the set. after adding it is working fine.


Rgds
Peter
 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

James Peter wrote:Hi Henry,

Thanks for adding code tag. I was about to do that.

Hi James,

thanks for your comment. I forgot to add "&" character in the set. after adding it is working fine.


Rgds
Peter



But did you fix the 'length' term and change to use matches() rather than find()?
 
James Peter
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes James, I changed and it is working.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!