1
履歴書から値(名前、電子メール、モバイルなど)を取得して、csv
ファイルに保存しようとしているcvパーサーに取り組んでいます。電話番号は取得できましたが、メールIDを取得できませんでした。私は下記のコードを使用しています。Javaのregexを使用して電子メールIDを取得しない
Pattern regex = Pattern.compile("[@]");
Matcher regexMatcher = regex.matcher(text);
int i = 0;
int width = 0;
while (regexMatcher.find()) {
if ((regexMatcher.start() - 10 > 0)
&& (regexMatcher.end() + 10 < text.length())) {
width = 10;
String[] substr = text.substring(
regexMatcher.start() - width,
regexMatcher.end() + width
).split(" ");
for (int j = 0; j < substr.length; j++) {
if (substr[j].contains("@")
&& (substr[j].contains(".com")
|| substr[j].contains("@")
&& substr[j].contains(".co.in")
|| substr[j].contains(".net"))) {
System.out.println(substr[j]);
email = substr[j];
}
}
} else {
System.out.println("NO MATCH");
}
}
Pattern p = Pattern.compile("\\d\\d\\d([,\\s])?\\d\\d\\d\\d\\d\\d\\d");
Matcher found = p.matcher(text);
if (found.find()) {
mobile = found.group();
System.out.println(mobile);
} else {
System.out.println("NO MATCH1");
}
ありがとうございます。 – sairam