Regex matching first capital letter followed by one or more small letters

前端 未结 2 2000
暗喜
暗喜 2021-01-26 09:32

That is my regular expression:

[A-Ö]{1}[a-ö]

When I write that everything is fine until I write another small letter it doesn\'t work. E.g.

相关标签:
2条回答
  • 2021-01-26 09:51
    [A-Ö]{1}[a-ö]*
    

    The * means zero or more, if you require a lowercase letter to follow, then use

    [A-Ö]{1}[a-ö]+
    
    0 讨论(0)
  • 2021-01-26 10:11

    Note that [A-Ö] matches all lower and uppercase letters and a lot of other symbols, too.

    You need

    [A-ZÖ][a-zö]+
    

    See regex demo

    Note that + matches 1 or more occurrences of the preceding subpattern.

    0 讨论(0)
提交回复
热议问题