Regex to match only letters

后端 未结 20 1546
孤城傲影
孤城傲影 2020-11-22 16:24

How can I write a regex that matches only letters?

20条回答
  •  粉色の甜心
    2020-11-22 16:41

    pattern = /[a-zA-Z]/

    puts "[a-zA-Z]: #{pattern.match("mine blossom")}" OK

    puts "[a-zA-Z]: #{pattern.match("456")}"

    puts "[a-zA-Z]: #{pattern.match("")}"

    puts "[a-zA-Z]: #{pattern.match("#$%^&*")}"

    puts "[a-zA-Z]: #{pattern.match("#$%^&*A")}" OK

提交回复
热议问题