This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Regex Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Regex" Watch "Regex" New topic
Author

Regex

joshua antony
Ranch Hand

Joined: Jun 05, 2006
Posts: 117



The output is

start: 1 group: 1+
start: 4 group: 3-
start: 7 group: 5=
start: 9 group: 45
start: 11 group: 45

I am not able to understand the last 2 lines of the output.
How come start: 9 group: 45
start: 11 group: 45 gets printed.

In this case we are searching for the first letter to be either 1,2,3,4 or 5 and the second one to be either _,- or =. isint it?
William Yan
Ranch Hand

Joined: Sep 26, 2006
Posts: 69
'+' is quantifier.
Maybe '-' is also quantifier too.
so

work.

Yours,
William


Java is better and better, yet bitter and bitter.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18917
    
  40

In this case we are searching for the first letter to be either 1,2,3,4 or 5 and the second one to be either _,- or =. isint it?


Interesting mistake... I probably would have made it myself.

It's the "-". It has special meaning used to specify a range, such as [a-z]. In this case, [+-=] means the range from the "+" to "=", which in the unicode table, includes the numbers.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
Consider Paul's rocket mass heater.
 
subject: Regex