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.
In the last movie, we took a look at a number of different regex engines. Now we need to install an engine of our own that we can use as we explore the regular expression syntax. There are a number of different tools that we could choose. Let's take a look at some of them. First, there is grep and egrep. You remember that those are UNIX tools, offered some of the earliest support for regular expressions. And if you have UNIX, Linux, or Mac OS X, then you already have those tools installed. The problem with them is because they were some of the earliest implementations of regular expressions, they don't have a lot of the advances that Perl brought.
So with Perl-compatible regular expressions, we're going to get a few extra features, but I would say grep and egrep are probably the biggest category of exceptions to some of the syntax that we're going to learn. So they aren't a great tool to use. There's a number of text editors that you could use: TextMate for Mac, E-TextEditor for Windows, BBEdit, EditPad Pro. There are many more text editors out there and IDEs--you certainly can use those. Most text editors have regular expression support, so you can just search a page of text and find out whether it has a match or not.
Now take note that these are text editors, not word processors. Something like Microsoft Word is a bad choice for working with regular expressions. It doesn't offer regular expression support. These are really designed to be code editors used by programmers who usually know about regular expressions, not consumers who usually don't know about regular expression, so make note of that difference. There's also a number of tools that are designed to help you write regular expressions and really show you more about what's going on. PowerGREP, regexBuddy, and regexMagic, these are all excellent tools.
The problem with them is that they're not cross platform. They either work on Mac or Windows, but not on both. As we saw in the last movie, there's also a number of programming languages that use regular expressions, and if you're an expert in one of those, you certainly could use each one of those to test out regular expressions. But I do want to require students of this course to learn one of those languages just to learn regular expressions. There's no need to do that. And some of you may be coming here with a .NET background, while someone else is coming here with a Ruby background. There are a number of different mobile applications that you could use for designing your regular expressions. For example, there are iPhone apps that will help you to craft them.
So here I am, at regexPal. This is the online version. You can see that here's the space where you would enter your regular expression, and here is the space where you would enter the data that you want to test to see if it matches the regular expression or not. I want you to notice just a couple more things about it. Notice there's these three boxes up here, checkboxes, that change things about the way the search works. We'll talk about those later, but just notice that there's three boxes at the top. And then over here is Quick Reference, which will give you some of the syntax that we're learning, in case you forget them, so those are both really helpful.
This checkbox here wasn't exposed in his version. It's actually there, but hidden. I've exposed it so that we can actually work with that, and that's the global, whether we want to search globally or not; but other than that, it's basically the same thing. So I'm going to encourage everyone to use the free exercise file version so we have the same thing in front of us, but you'll have the online version as a fallback.
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.