Forums Register Login

Regular Expression Doubt

+Pie Number of slices to send: Send
source : "1 a12 234 b"
pattern: \d+

It prodces the output as 036 but in Kathy Seria's book (P-477) it's written that it produces

0 1
3 12
6 234
+Pie Number of slices to send: Send
Running the program on page 483 gives:


You have the 0, 3, 6 (start positions) correctly, where are your groups?
+Pie Number of slices to send: Send
On Page 483, the pattern is /d/w and not /d+.

My Question is :

On page 477, using /d+ as pattern he produces the output as

0 1
3 12
6 234


is that incorrect ?
+Pie Number of slices to send: Send
As I wrote,running the program on 487 with source : "1 a12 234 b"
pattern: \d+
produces
0 1
3 12
6 234
[ October 02, 2006: Message edited by: Barry Gaunt ]
+Pie Number of slices to send: Send
I got it. It's the Matcher group() method which produces that output.

Then surely there is a mistake in kathy's book on p - 477....
+Pie Number of slices to send: Send
 

Originally posted by Sandeep Vaid:
I got it. It's the Matcher group() method which produces that output.

 
You don't like waffles? Well, do you like this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 575 times.
Similar Threads
i cant ...... learn to use the split
how it works
Conversion of Array into List
doubt regarding pattern matching in java
Jtable and Scrollbar
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:14:33.