File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes scanner findInLine method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "scanner findInLine method" Watch "scanner findInLine method" New topic
Author

scanner findInLine method

Ankit Gareta
Ranch Hand

Joined: Mar 28, 2011
Posts: 67

Hi all,


I can't understand the output, actually i m confused on "s.findInLine("(\\d+) fish (\\d+) fish (\\w+) fish (\\w+)");" this line. what this line actually want to say ?

Thanks in advance.
Ankit


OCPJP 6 (91%)
Nikhil Sagar
Ranch Hand

Joined: Apr 21, 2012
Posts: 216

Ankit Gareta wrote:Hi all,


I can't understand the output, actually i m confused on "s.findInLine("(\\d+) fish (\\d+) fish (\\w+) fish (\\w+)");" this line. what this line actually want to say ?

Thanks in advance.
Ankit


In your case findInLine() says that-
Find, "(\\d+) fish (\\d+) fish (\\w+) fish (\\w+)" in String s.


OCPJP 6 86%
Ankit Gareta
Ranch Hand

Joined: Mar 28, 2011
Posts: 67

Is this "(\\d+) fish (\\d+) fish (\\w+) fish (\\w+)" String pattern doesn't return only one token where the Scanner string is "1 fish 2 fish red fish blue fish" ?
because first one or more digit then fish(2 times), then one or more words then fish...that will get in whole line.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: scanner findInLine method