2
試圖從字符串中提取年,但這似乎並沒有工作:斯卡拉正則表達式:如何從字符串中提取年份?
val p = "(19|20)\\d\\d".r
val str = "At the time of its release, Twilight Princess was considered the greatest entry in the Zelda series by many critics, including writers for 1UP.com, Computer and Video Games, Electronic Gaming Monthly, Game Informer, GamesRadar, IGN, and The Washington Post. It received several Game of the Year awards, and was the most critically acclaimed game of 2006. In 2011, the Wii version was rereleased under the Nintendo Selects label. A high-definition port for the Wii U, The Legend of Zelda: Twilight Princess HD, will be released in March 2016."
println(p.findAllIn(str).toSeq)
它給了我:
Seq[String] = Stream(2006, ?)
缺少了「2016」和「2011」加上一個額外的「? 」。任何想法,我要去錯了嗎?