Split string based on regex

后端 未结 3 1790
后悔当初
后悔当初 2020-12-01 00:44

What is the best way to split a string like \"HELLO there HOW are YOU\" by upper case words (in Python)?

So I\'d end up with an array like such:

3条回答
  •  误落风尘
    2020-12-01 00:56

    Your question contains the string literal "\b[A-Z]{2,}\b", but that \b will mean backspace, because there is no r-modifier.

    Try: r"\b[A-Z]{2,}\b".

提交回复
热议问题