/

HTML / CSS / JavaScript Tutorial

JavaScript regular expression property: ignoreCase

[this page | pdf | back links]

The ignoreCase property of a JavaScript regular expression indicates if the i modifier is set within the regular expression.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
table,th,tr,td {border: 1px solid black; border-collapse: collapse;}
</style>
</head>
<body>
<table>
<tr>
<th>Example</th>
<th>Resulting value of <code>x</code></th>
</tr>
<tr>
<td><code id="Example"></code></td>
<td><code id="Result"></code></td>
</tr>
</table>

<script>
var str = "Hello World";
var patt = /o(!= W)/gim;
document.getElementById("Example").innerHTML =
  'var str = "Hello WORLD";' + '<br>' +
  'var patt = /o/gim;' + '<br>' +
  'var y = str.replace(/o(!= W)/gi,"*");' + '<br>' +
  'var x = patt.ignoreCase;';
document.getElementById("Result").innerHTML
  = patt.ignoreCase;
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | JavaScript Regular Expressions


Desktop view | Switch to Mobile