How to represent a fix number of repeats in regular expression?

后端 未结 4 1556
北荒
北荒 2021-02-01 12:06

I am wondering if there is a better to represent a fix amount of repeats in a regular expression. For example, if I just want to match exactly 14 letters/digits, I am using

4条回答
  •  情歌与酒
    2021-02-01 12:45

    ^\w{14}$ in Perl and any Perl-style regex.

    If you want to learn more about regular expressions - or just need a handy reference - the Wikipedia Entry on Regular Expressions is actually pretty good.

提交回复
热议问题