Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- /**
- * Created by Gosho PC on 17.6.2016 г..
- */
- public class ExtractEmails {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- String text = reader.readLine();
- Pattern pattern = Pattern.compile("([A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*@(?:[A-Za-z]+\\-?[A-Za-z]+\\.)+[A-Za-z]+\\-?[A-Za-z]+)\\b");
- Matcher matcher = pattern.matcher(text);
- while(matcher.find()) {
- System.out.println(matcher.group());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement