This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

scanner findInLine method  RSS feed

 
Ankit Gareta
Ranch Hand
Posts: 67
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Nikhil Sagar
Ranch Hand
Posts: 216
Java Linux Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ankit Gareta
Ranch Hand
Posts: 67
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!