Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Matcher matches = Pattern.compile("T\d+").matcher("T234bird");
- System.out.println(matches.lookingAt()); //after running this, find() will return false
- while (matches.find())
- System.out.println(matches.group());
- //Output: true
- Matcher matches = Pattern.compile("T\d+").matcher("T234bird");
- //System.out.println(matches.lookingAt()); //without this, find() will return true
- while (matches.find())
- System.out.println(matches.group());
- //Output: T234
- Matcher matches = Pattern.compile("T\d+").matcher("T234bird");
- while (matches.lookingAt())
- System.out.println(matches.group());
- //Output: T234 T234 T234 T234 ... till crash
- //I understand why this happens. It's not my question but I just included it in case someone may try to suggest it
- Matcher matches = Pattern.compile("T\d+").matcher("T234bird");
- if(matches.lookingAt())
- System.out.println(matches.group());
- //Output: T234
- Matcher matches = Pattern.compile("T\d+").matcher("T234bird");
- if (matches.lookingAt())
- System.out.println(matches.group());
- Matcher matches = Pattern.compile("^T\d+").matcher("T234bird");
- if (matches.find())
- System.out.println(matches.group());
Add Comment
Please, Sign In to add comment