Capture all consecutive all-caps words with regex in python?

后端 未结 4 965
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-10 20:08

I am trying to match all consecutive all caps words/phrases using regex in Python. Given the following:

    text = \"The following words are ALL CAPS. The follow         


        
4条回答
  •  感情败类
    2021-02-10 21:05

    Assuming you want to start and end on a letter, and only include letters and whitespace

    \b([A-Z][A-Z\s]*[A-Z]|[A-Z])\b
    

    |[A-Z] to capture just I or A

提交回复
热议问题