Advertisement
Guest User

Extract

a guest
Jun 18th, 2016
791
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.regex.Matcher;
  7. import java.util.regex.Pattern;
  8.  
  9. public class Main {
  10.  
  11.     public static void main(String[] args) throws IOException {
  12.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  13.         String input = br.readLine();
  14.         StringBuilder sb = new StringBuilder();
  15.  
  16.         String regex = "^|\\s[a-z0-9][\\.\\_\\-a-z0-9]*[a-z0-9]@[a-z0-9][\\.\\-a-z0-9]*[a-z0-9]\\.[a-z]{2,}";
  17.         Pattern pattern = Pattern.compile(regex);
  18.         Matcher matcher = pattern.matcher(input);
  19.  
  20.         while (matcher.find()) {
  21.             sb.append(matcher.group() + "\n");
  22.         }
  23.  
  24.         System.out.println(sb.toString());
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement