Viewers: in countries Watching now:
Learn how to find and manipulate text quickly and easily using regular expressions. Author Kevin Skoglund covers the basic syntax of regular expressions, shows how to create flexible matching patterns, and demonstrates how the regular expression engine parses text to find matches. The course also covers referring back to previous matches with backreferences and creating complex matching patterns with lookaround assertions, and explores the most common applications of regular expressions.
Now that we have a text editor, I just wanted to make a couple of notes about the conventions that we're going to be using throughout this tutorial. The first is that whenever we have a regular expression you're going to see it inside forward slashes. So /abc/, abc would be the regular expression. This notation with the two forward slashes is a convention, and it's used all the time. You'll see regular expressions inside those forward slashes, and it really comes back from the very beginnings of regular expressions. You'll remember when I told you about the history, I said that was traditionally in the ed text editor g/ and then the regular expression /p. So that's where those forward slashes come from.
However, when you use these in that regexPal that we're working with, you will not use the forward slashes. The forward slashes do not get entered in there, just the actual regular expression itself. Okay, so everything in between there is what you're going to input. The same thing, with the text string, whenever you see a text string on the screen, you're going to see it with quotes around it, but when you enter it into regexPal, you're going to enter it without the quotes, just abc. But when you see quotes around it like that, you'll know that it's a string.
So with the slashes on either side, it tells you it's a regular expression; the quotes tell you that it's a text string. Now if you're using another tool besides the regexPal tester and you're using these in another language, that language may require you to put your regular expression inside slashes, or your string inside quotes. You'll need to do that as is appropriate for that language. Now there's another important notation convention that you should know about, which is modes. Regular expression comes in several different modes. There's the Standard mode, which is just the regular expression by itself.
There is a Global mode, a global search, where the g comes after it instead of being before it, like it used to be back in the UNIX days. We put after it; that lets us know it's going to global. An i that tells us it's going to be case-insensitive. m is for Multiline mode, and S for Dot-matches-all mode. We'll talk about those a little later on, but I just want you to see that the mode goes right after those slash. It's not actually part of the regular expression; it's a modifier for the way that this regular expression ought to be handled. Now let's take a look at regexPal and look how these are implemented there.
Now in regexPal, you can see that those modes are up here across the top. So, if we're talking about something in Case-insensitive mode, well then we need to check that. That's the equivalent of putting the i after the slash. Actually it's equivalent of putting bot the g and the i after the slash since they're both checked. If we uncheck Global, now it's only the i, and so on, with the m and the s as well. In the online version of this tool, remember, Global is hidden. It's always assumed to be a global search. That's not a big deal. I just wanted to be able to demonstrate to you a little later on what the difference is between a regular search and a global search.
So that's how you enable these different modes in the regexPal, and most other programming languages and tools are going to have some way that you can get to these different modes and enable them. For now I just wanted you to understand what the standard notation is and how they're normally handled and then see how they're handled in regexPal.
There are currently no FAQs about Using Regular Expressions.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.