Regex: match only letters WITH numbers

前端 未结 4 2147
梦谈多话
梦谈多话 2021-02-13 22:02

How can I create a regex expression that will match only letters with numbers?

I\'ve tried something like (?>[A-z]+)([a-z0-9]+).

4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-13 22:23

    (?:\d+[a-z]|[a-z]+\d)[a-z\d]*

    Basically, where 1 and a are any number and any letter, it matches 1a or a1, surrounded by any number of alphanumeric characters.

    edit: shorter and probably faster now

提交回复
热议问题