Case insensitive search in JavaScript

Case-insensitive: It means the text or typed input that is not sensitive to capitalization of letters, like “Geeks” and “GEEKS” must be treated as same in case-insensitive search. In Javascript, we use string.match() function to search a regexp in a string and match() function returns the matches, as an Array object.
Syntax:
string.match(regexp)
Parameters: This method accepts single parameter regexp which is required. It is used to pass the value to search for as a regular expression.
Regular expression (regexp): It is a particular syntax /pattern/modifiers; modifier sets the type. For example /zambiatek/i where “i” sets to case insensitive.
Note: Here g and i used for global and case-insensitive search respectively.
Example 1: This example describes the search of a regular expression.
HTML
| <!DOCTYPE html><html><head>    <title>        Case insensitive search        in JavaScript    </title></head><bodystyle= "text-align:center;">    <h1style= "color:green;">             zambiatek     </h1>        <p>        Click on button    </p>    <buttononclick="myGeeks()">        Click Here!    </button>    <pid="GFG"></p>    <script>        function myGeeks() {            var str = "Welcome Geeks GEEKS zambiatek";             var res = str.match(/zambiatek/gi);                        document.getElementById("GFG").innerHTML                    = res;        }    </script></body></html>                     | 
Output:
- Before clicking on the button:
- After clicking on the button:
Example 2: This example describes the search of a regular expression.
HTML
| <!DOCTYPE html><html><head>    <style>        h1 {            padding-top: 35px;            color: green;        }    </style></head><bodystyle="text-align:center;">    <h1>zambiatek</h1>    <p>Click the button to perform a global                      case-insensitive search.</p>    <buttononclick="myFunction()">Try it</button>    <pid="demo"></p>    <script>        function myFunction() {            var str = "Brazil and Austraila won the WorldCup 5 times";            var res = str.match(/5/gi);            document.getElementById("demo").innerHTML = res;        }    </script></body></html> | 
Output :-
- Before clicking on button
- After clicking on button:
 
				 
					



