In the following example, RegExp.input is set by the Change event. In the getInfo function, the exec method uses the value of RegExp.input as its argument. Enter your first name and your age, and then press Enter. The following example is similar to Example 2. Enter your first name and your age, and then press Enter.
Regular expressions have two optional flags that allow for global and case insensitive searching.
To indicate a global search, use the g flag. To indicate a case insensitive search, use the i flag. These flags can be used separately or together in either order, and are included as part of the regular expression. Note that the flags, i and g, are an integral part of a regular expression. They cannot be added or removed later.