Regex for non-consecutive upper-case words

后端 未结 5 1187
抹茶落季
抹茶落季 2021-01-14 17:15

Here\'s one for you Regex wizards.

This is for use within Notepad++, i.e. it is entered directly into the search and replace dialog.

I need

5条回答
  •  死守一世寂寞
    2021-01-14 17:45

    I would try

    (^|\.\s+|[a-z]\s+)([A-Z]+)(\.|\s+[a-z]|$)
    

    That matches: a period or start-of-line or end of a lowercase word; followed by an uppercase word; followed by a period, end-of-line or start of a lowercase word.

    The word itself is matched in group 2. If Notepad++ supports lookaround assertions, you can do this so that the only captured word is the single capitalized word:

    (?:^|\.\s+|[a-z]\s+)([A-Z]+)(?:\.|\s+[a-z]|$)
    

提交回复
热议问题