Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String Reading Problem

 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys here is the code


i am not understanding what does actually "([A-Z\\d]{2}\\s+\\d+)" this string is doing please guide me to understand this
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a pretty good website on regex to provide you with some guidance:
http://www.regular-expressions.info/

As to your specific question, break it down into parts.

What does this part match?


Now what does this part match?


It's pretty confusing when you try to look at it as a whole, but when you break it down into parts it's much simpler. You can test your patterns for matches using the java.util.regex.Matcher class.

example:


Hunter
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Java™ Tutorials section is another good resource about regular expression.
 
john chris
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could read java.util.regex.Pattern.class
 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i actually wants to know what
pattern.compile and abc.matcher do...
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then check out the Javadoc of java.util.regex.Pattern.
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:Then check out the Javadoc of java.util.regex.Pattern.
Akhter Wahab, somebody else has already referred you to that class. Did you read the links quoted earlier?
 
akhter wahab
Ranch Hand
Posts: 151
Java MyEclipse IDE Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Rob Prime wrote:Then check out the Javadoc of java.util.regex.Pattern.
Akhter Wahab, somebody else has already referred you to that class. Did you read the links quoted earlier?


sorry Campbell Ritchie i didn't... now i got it

thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic