Results 1 to 1 of 1
-
Using Scanner with regex.MatchResult
The example below shows how to use regex.MatchResult and Scanner to find the required matches.
Java Code:String input = "1 fish 2 fish red fish blue fish"; Scanner s = new Scanner(input); s.findInLine("(\\d+) fish (\\d+) fish (\\w+) fish (\\w+)"); MatchResult result = s.match(); for (int i=1; i<=result.groupCount(); i++) System.out.println(result.group(i)); s.close();
Similar Threads
-
Regex for file extension
By gapper in forum New To JavaReplies: 1Last Post: 01-31-2008, 03:59 PM -
Regex Quantifiers Example
By Java Tip in forum Java TipReplies: 0Last Post: 01-10-2008, 10:44 AM -
REGEX - predefined character classes
By Java Tip in forum Java TipReplies: 0Last Post: 01-10-2008, 10:42 AM -
Regex pattern
By ravian in forum New To JavaReplies: 4Last Post: 12-11-2007, 10:20 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks