var str = "I learn JavaScript";
// Add "i" modifier to make search case-insensitive:
alert( str.search( /javascript/i ) ); // 8
var str = "I learn JavaScript";
alert( str.search("PHP") ); // -1, not found
alert( str.search("JavaScript") ); // 8
alert( str.search("javascript") ); // -1, letter-casing mismatch
Tip: you can also perform case-insensitive searches with search() with string argument or indexOf() by first converting the "searched" string toLowerCase() or toUpperCase().
$str = 'I learn PHP';
$found = preg_match( '/php/i' , $str ); // case-insensitive search
if( $found == 1 ) // Returns 1 if matched
echo 'You *are* learning PHP!';
Sister method: replace() substitutes RegExp pattern matches in one string with another string.