Guest User

Untitled

a guest
May 24th, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.regex.Matcher;
  3. import java.util.regex.Pattern;
  4.  
  5.  
  6. public class _08_ExtractEmails {
  7.  
  8.     public static void main(String[] args) {
  9.  
  10.         Scanner sc = new Scanner(System.in);
  11.        
  12.         String input = sc.nextLine();
  13.         Pattern regex = Pattern.compile("\\w+([.-_]+\\w+)*@\\w+([.]\\w+)+");
  14.         Matcher matcher = regex.matcher(input);
  15.  
  16.        
  17.         while(matcher.find()){
  18.             System.out.println(matcher.group());
  19.         }
  20.     }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment