こんにちは、メールからフッターを削除する方法を教えてください。メールの本文を保存し、免責事項やフッターなどの他のものを削除するだけです。
質問する
641 次
2 に答える
-1
正規表現を使用できます。
メールが次のように見えるとしましょう
String emailContents =
"AAA this is the email header BBB\n" +
"This is the body\n" +
"CCC this is the email footer DDD";
次のようなことができます。
Pattern pattern = Pattern.compile("AAA.*BBB(.*)CCC.*DDD");
Matcher matcher = pattern.matcher(emailContents);
if (!matcher.matches()) throw new Exception("Invalid email");
String emailBody = matcher.group(1);
System.out.println(emailBody); // prints 'This is the body'
于 2013-11-07T09:54:00.353 に答える