我需要找到一个匹配每个句子的正则表达式,无论它是否跟随标题大小写(句子的每个单词的第一个字母应该是大写的,并且单词也可以包含特殊字符).
regex101
原文链接:https://www.f2er.com/regex/357007.html([A-Z][^\s]*)
描述
1st Capturing group ([A-Z][^\s]*) [A-Z] match a single character present in the list below A-Z a single character in the range between A and Z (case sensitive) [^\s]* match a single character not present in the list below Quantifier: * Between zero and unlimited times,as many times as possible,giving back as needed [greedy] \s match any white space character [\r\n\t\f ] g modifier: global. All matches (don't return on first match)
^(?:[A-Z][^\s]*\s?)+$
描述
^ assert position at start of the string (?:[A-Z][^\s]*\s?)+ Non-capturing group Quantifier: + Between one and unlimited times,giving back as needed [greedy] [A-Z] match a single character present in the list below A-Z a single character in the range between A and Z (case sensitive) [^\s]* match a single character not present in the list below Quantifier: * Between zero and unlimited times,giving back as needed [greedy] \s match any white space character [\r\n\t\f ] \s? match any white space character [\r\n\t\f ] Quantifier: ? Between zero and one time,giving back as needed [greedy] $assert position at end of the string