Want to find whether my string contains every digit from 0 to 9 or not. I am currently using following logic :
if (str.contains("0") && str.contains("1") && str.contains("2") && str.contains("3") && str.contains("4") && str.contains("5") && str.contains("6") && str.contains("7") && str.contains("8") && str.contains("9"))
{
return true;
}
I believe this will not be very optimized if string is too big. How can I use a pattern and find using String.matches whether it has all numbers or not through regex ?
This is not a duplicate of most other regex questions in the forum wherein 'OR' related char patterns are discussed, here we're talking about 'AND'. I need whether a string contains each of the given characters (i.e. digits) or not. Hope it clarifies.
Thanks, Rajiv