Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class regExMatchFullName {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String imput = scanner.nextLine();
- String regex = "\\b[A-Z][a-z]+ [A-Z][a-z]+\\b";
- Pattern pattern = Pattern.compile(regex);
- Matcher matcher = pattern.matcher(imput);
- while (matcher.find()){
- System.out.print(matcher.group()+" ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement