Answers for "how to find if a word contains a certain character in a string"

PHP
2

How do I check if a string contains a specific word?

$a = 'Hello world?';

if (strpos($a, 'Hello') !== false) { //PAY ATTENTION TO !==, not !=
    echo 'true';
}
if (stripos($a, 'HELLO') !== false) { //Case insensitive
    echo 'true';
}
Posted by: Guest on May-18-2020
0

how to check if a string contains a character

public static boolean containsIgnoreCase(String str, char c) {
        str = str.toLowerCase();

        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == Character.toLowerCase(c)) {
                return true;
            }
        }
        
        return false;
    }
Posted by: Guest on April-14-2020

Code answers related to "how to find if a word contains a certain character in a string"

Browse Popular Code Answers by Language