| Author |
Regex question
|
Dinesh Tahiliani
Ranch Hand
Joined: Aug 06, 2007
Posts: 486
|
|
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()); } } } Answer is --01234456 Can someone expalin me the use of group?
|
Thanks<br />Dinesh
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
|
See our SCJP FAQ: Could someone explain the Regex2 class from K&B's Java 5 Study Guide?
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
 |
|
|
subject: Regex question
|
|
|