【发布时间】:2010-10-11 03:10:46
【问题描述】:
如何匹配可以在任何地方发生换行符的正则表达式?
例如,如果我要匹配“千龟蛋”,它应该匹配以下所有情况。 (甚至是换行符在单词内的情况。)
Scientists have revealed that a mammoth effort to move *thousands of turtle eggs* from beaches around the Gulf of Mexico after the Deepwater Horizon oil spill may have saved almost 15,000 of the reptiles.
Scientists have revealed that a mammoth effort to move *thousands
of turtle eggs* from beaches around the Gulf of Mexico after the Deepwater Horizon oil spill may have saved almost 15,000 of the reptiles.
Scientists have revealed that a mammoth effort to move *thousands of
turtle eggs* from beaches around the Gulf of Mexico after the Deepwater Horizon oil spill may have saved almost 15,000 of the reptiles.
Scientists have revealed that a mammoth effort to move *thousands of turtle
eggs* from beaches around the Gulf of Mexico after the Deepwater Horizon oil spill may have saved almost 15,000 of the reptiles.
【问题讨论】:
-
下一次,请向我们提供有关您正在使用哪个正则表达式库或哪个应用程序的信息,因为不同的库/应用程序会给出不同的正确答案。您还可以通过选择多个适当的标签来发出信号。
-
@Vantomex 正则表达式库重要吗?我可以用一个通用的答案来做,而不是绑定到任何库/应用程序。 - 谢谢
-
并非每个正则表达式库都支持所有格量词、原子分组等。它们可用于优化库的正则表达式解析速度。此外,为了在正则表达式库之间实现相同的结果,它们存在许多规则差异。
标签: regex