scala regex - 在句点字符之间找到句子

时间:2014-05-04 03:14:32

标签: regex scala

我正在尝试在两个fullstops(句点)之间找到句子。我尝试了以下表达式,但这似乎跳过了每个替代句子。

"\\..+?\\.".r.findAllIn("''Super Ducktales'' is an [[Ducktales]]'s episode.  ==Plot== ===Part 1:Liquid assetats=== When the Ma Beagle's birthday is next, the Beagles sabote the new Duckburg's freeway plant to make that the freeeway pass '''acroos''' the Money Bin. After discovery it, [[Scrooge McDuck]] goes talk with the pig major but he can't accept chenge the plant. After, at [[Manor McDuck]], Scrooge realize that he need contract a accounter.").foreach(println(_))

输出是:

.  ==Plot== ===Part 1:Liquid assetats=== When the Ma Beagle's birthday is next, the Beagles sabote the new Duckburg's freeway plant to make that the freeeway pass '''acroos''' the Money Bin.
. After, at [[Manor McDuck]], Scrooge realize that he need contract a accounter.

作为这个问题的第二部分,我还想提取第一句话。有没有办法合并^符号?

斯卡拉的知识非常有限

1 个答案:

答案 0 :(得分:1)

这是因为正则表达式在移动时消耗。这样做:

"\\.[^.]+"