A Regular Expression (regex) is a sequence of characters that define a pattern that allows you to search, match, locate, replace, manipulate, and manage text. Regular expressions are very powerful, but also difficult to understand and complicated to use. But sometimes a regular expression is a the most optimal, or the only solution for a task.
The four letters inside the regular expression delimiters are character literals. Shown below is an example of how this regular expression could be used.
<script> var strTarget = "abcdefghijkl"; var loc = strTarget.search(/efgh/); alert(loc); </script>
In case you are not familiar with how to execute code like that shown above. Open a new text file (use a basic ASCII text editor like Windows Notepad, not a word processor. Word processors add formatting characters to the text). Paste the code shown above into the text file. Save the text file with a name that has the file extension .htm. (say test.htm) Double-click on the file to open it in your web browser.
Now I know many of you already know how to execute code like that shown above. I don't mean to insult your intelligence. But I need to explain the above because the this is the method I will use to in future articles in this series, and I promise you things will get more advanced in future articles. Way more advanced.
Learn more at amazon.com