How can I check if a string contains all question marks? Like this:
string input = "????????";
Read the String. Convert all the characters in the given String to lower case using the toLower() method. Convert it into a character array using the toCharArray() method of the String class. Find whether every character in the array is in between a and z, if not, return false.
You can use contains(), indexOf() and lastIndexOf() method to check if one String contains another String in Java or not. If a String contains another String then it's known as a substring. The indexOf() method accepts a String and returns the starting position of the string if it exists, otherwise, it will return -1.
The includes() method returns true if a string contains a specified string. Otherwise it returns false . The includes() method is case sensitive.
Use the test() method to check if a string contains only digits, e.g. /^[0-9]+$/. test(str) . The test method will return true if the string contains only digits and false otherwise. Copied!
var isAllQuestionMarks = input.All(c => c == '?');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With