Python regex to match punctuation at end of string

后端 未结 3 1795
伪装坚强ぢ
伪装坚强ぢ 2021-02-15 17:40

I need to match if a sentence starts with a capital and ends with [?.!] in Python.

EDIT It must have [?.!] only at end but allo

3条回答
  •  盖世英雄少女心
    2021-02-15 18:05

    Your regex checks for a single digit in the range [A-Z]. You should change to something like:

    ^[A-Z].*[?.!]$
    

    Change the .* to whatever you want to match between the capital letter and the punctuation at the end of the string.

提交回复
热议问题