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
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
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
regex question
cathymala louis
Ranch Hand
Posts: 77
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
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.println(m.start() + m.group()); } } }
The command line values:
args[0] - "\d*"
args[1] - ab34ef
The answer given is 01234456.
I can able to understand 0123445. But please explain me how that 6 come.
Zip Ped
Ranch Hand
Posts: 336
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
That's because your
string
starts at index 0 and ends at index 6. A better explaination is
here
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Regex Doubt
kb p. 498
Regarding regex
searching for "\d*" in a string
Parsing, Tokenizing and Formatting
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
More...