[英]Match specific dots in sentences
I want to add spaces where needed (after .
) in sentences. 我想在句子中(在.
之后)添加空格。 When a .
当一个.
is not followed by another .
之后没有另一个.
or a space, a space should be added. 或空格,应添加一个空格。
I've came up with that regex : 我想出了该正则表达式:
\.(?![ \.])
There is only one problem, if the .
如果仅存在一个问题.
is at the end of the string, it should not be selected. 在字符串的末尾,不应选择它。
Example : 范例:
Here is a test sentence...Here is another sentence. 这是一个测试句子...这是另一个句子。
Should select : Here is a test sentence.. .
应该选择:这是一个测试句子.
Here is another sentence. 这是另一句话。
but my solution select : 但我的解决方案选择:
Here is a test sentence.. .
这是一个测试语句.
Here is another sentence .
这是另一句话.
After the regex, all groups will be replaced by ". ". 正则表达式之后,所有组都将替换为“。”。 This part is already done and working. 这部分已经完成并正在工作。
ShellFish使我步入正轨,提出了这个有效的正则表达式:
\.(?![\.\s])
另一种选择是使用正向先行
\.(?=\w)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.