Regex: Check if string contains at least one digit

后端 未结 9 2077
盖世英雄少女心
盖世英雄少女心 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:51

    In Java:

    public boolean containsNumber(String string)
    {
        return string.matches(".*\\d+.*");
    }  
    

提交回复
热议问题