Perform a case-insensitive search: - Javascript String

Javascript examples for String:search

Description

Perform a case-insensitive search:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*  w  w  w . ja  va 2s. co  m*/
    var str = "Blue blue red"
    var n = str.search(/blue/i);
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>

Related Tutorials