Regex that finds consecutive words with first letter capitalized

前端 未结 4 1588
忘了有多久
忘了有多久 2020-12-18 09:02

I am looking for a regex that can identify in a sentence that consecutive words in a sentence start with capital letters.

If we take the text below as an example:

4条回答
  •  [愿得一人]
    2020-12-18 09:31

    Start off by thinking in non-technical terms. What do you want? A "word" followed by one or more groups of "a word separator followed by a word"

    Now you just need to define the pattern for a "word" and a "word separator", and then combine those into a complete pattern.

    When you break it down like that, a complex regex is nothing more than a few very simple pattern groups.

提交回复
热议问题