Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
TDD for a Shopping Website LiveProject
this week in the
Testing
forum!
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
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Paul Clapham
Ron McLeod
Jeanne Boyarsky
Tim Cooke
Sheriffs:
Liutauras Vilda
paul wheaton
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Carey Brown
Frits Walraven
Bartenders:
Piet Souris
Himai Minh
Forum:
Programmer Certification (OCPJP)
Greedy quantifiers(*)
K Raj Kumar
Greenhorn
Posts: 17
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi Ranchers!
import java.util.regex.*; class Regex2{ public static void main(String [] args){ Pattern p = Pattern.compile(args[0]); Matcher m= p.matcher(args[1]); boolean b= false; while(b=m.find()) { System.out.print(m.start() + m.group()); } } }
java
Regex2 "\d*" ab34ef
Output:01234456
I am unable to interpret the last part of the output esp at"456".
So,please help me in understanding it.
Source:
SCJP
6 study java guide, Kathy sierra and Bert bates, Self
Test
,Page 515.
Thanks in advance!
With Regards,<br />K.Raj Kumar.
Punit Singh
Ranch Hand
Posts: 952
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import java.util.regex.*; public class Regex2{ public static void main(String [] args){ Pattern p = Pattern.compile("\\d*"); Matcher m= p.matcher("ab34ef"); boolean b= false; while(b=m.find()) { System.out.print("index is: "+m.start()); System.out.print(" Group is: "+m.group()); System.out.println(); } } }
Run this and try to understand it is very simple.
SCJP 6
Ankit Garg
Sheriff
Posts: 9692
42
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
This question is answered comprehensively in FAQ. The link is in my signature...
SCJP 6 | SCWCD 5 |
Javaranch SCJP FAQ
|
SCWCD Links
I am displeased. You are no longer allowed to read this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
doubt regarding patterns in regex
Regex Program
Regex Question from K&B
confused about Scanner class
regex
More...