我有一个有趣的正则表达式问题。说我有这样的段落
Johannesburg (; Afrikaans: ; also known as Jozi, Jo'burg, and eGoli) is the largest city in South Africa and one of the 50 largest urban areas in the world. It is the provincial capital and largest city of Gauteng, which is the wealthiest province in South Africa. While Johannesburg is not one of South Africa's three capital cities, it is the seat of the Constitutional Court. The city is located in the mineral-rich Witwatersrand range of hills and is the centre of large-scale gold and diamond trade.
该正则表达式(^.*?[a-z]{2,}[.!?])\s+\W*[A-Z]能够很好地根据句子构造逻辑找到第一句。当我只有一句这样的话时,问题就来了。
Johannesburg (; Afrikaans: ; also known as Jozi, Jo'burg, and eGoli) is the largest city in South Africa and one of the 50 largest urban areas in the world.
它与这句话不匹配是可以理解的,因为后面没有别的句子。我现在的问题是如何调整这个表达式,使其适用于这两种情况?
https://stackoverflow.com/questions/55807681
复制相似问题