2012-11-23 52 views

回答

3

這是我自己的嘗試:

scala> import scala.io.Source.fromFile 

scala> val r = """(?i)\b[A-Z0-9._%+-][email protected][A-Z0-9.-]+\.[A-Z]{2,4}\b""".r 

scala> fromFile("./mails").getLines.flatMap { r.findAllIn _ }.toList 
res29: List[String] = List([email protected], [email protected], [email protected]) 

Source for the RegEx.

+0

本應包含在你的問題! – Anirudha

+3

@ Some1.Kill.The.DJ:不是。我想這是一個有效的答案,如果他發現最好,OP甚至可以自我接受。 –

+2

您的正則表達式在某些地址上會失敗([email protected],[email protected]等)。看看[這裏](http://www.regular-expressions.info/email.html)。 –

相關問題