Regex: Check if string contains at least one digit

后端 未结 9 2090
盖世英雄少女心
盖世英雄少女心 2020-12-09 07:40

I have got a text string like this:

test1test

I want to check if it contains at least one digit using a regex.

What would this reg

9条回答
  •  春和景丽
    2020-12-09 07:57

    In perl:

    if($testString =~ /\d/) 
    {
        print "This string contains at least one digit"
    }
    

    where \d matches to a digit.

提交回复
热议问题