Perl Regex - Replace the ending of sentences to be period, one whitespace, capital letter
我正在尝试开发一个regex,用更干净的句子结尾替换混乱的句子结尾。
例如,转动:
1 | the quick.brown fox. jumped over! the slow. dog |
进入:
1 | The quick. Brown fox. Jumped over. The slow. Dog |
以下是我目前为止的情况:
1 2 3 |
结果是:
1 | the quick.brown fox. jumped over! the slow. dog |
我搞不清楚如何强制使用句号和单个空格。
感谢您的帮助,谢谢!
我认为这会满足你的需求:
1 2 3 | my $test = ucfirst('the quick.brown fox. jumped over! the slow. dog'); $test =~ s/[.?!]\s*([a-z]?)/. \U$1/img; say $test; |
如您所见,我移动了开头的
注意,在
@Borodin的编辑在