To understand how this is done, we first we need to see how regular expressions are used in JavaScript. The great power of regular expressions is that they are flexible, i.e., they have the ability to match a wide range of strings, from specific words to general patterns. In the following text, we'll discuss the details of this and many other simple variations that can be made to tailor the base expression to match nearly any criteria that is necessary.
The original Regular Expression can be easily modified to be case insensitive and to match all occurrences through the addition of some special characters. For example, the following sentence includes two occurrences of "dog." The regular expression above will find only the first one. It will not match "Dog" or "DOG" or "doog." Also, it will only match the first occurrence of "dog" in the text to which it is applied. It matches them in the order and case in which they are written.
It is case sensitive and it matches the specified characters verbatim, nothing more and nothing less. This regular expression matches the word "dog." The expression does not contain any special characters (only standard-text characters). These forward slashes are the syntax that indicates (delimits) a Regular Expression. It is a mixture of both regular text characters and characters with special meaning, enclosed in forward slashes, "/". Its just a matter of easing in to learning the syntax.Ī regular expression is simply a string of characters that represent a text pattern. While regular expressions seem complex (and sometimes are very complex), they can actually be quite simple to build and easy use. In Core JavaScript, regular expressions are a built-in data type and are employed in several of the standard string operations. Of course this includes the Core JavaScript model. They have been tested by the ages and been found to be so useful that practically every computer language in use today provides support for using regular expressions. Regular expressions are an ancient and powerful technique for finding patterns in text.