Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now I'm not going to go through all of these item by item, but you can pause the movie if you want to take a look. Really get a feel for what they do. First a simple period, that's a wild card. The character set, so that's any character listed inside those square brackets. So in the example on the far right you can see that that would match both grey and gray, both spellings of gray could get matched. Then we have a negative character set. We'd have the same square brackets but we put a caret as the first character inside of them and that would say any character that's not included there. So for example, if we wanted to match everything that was not an A, E, I, O or U, then we would use that negative character set.
Next we have the range indicator which is a minus sign and that's typically just used inside a character set to indicate a range of characters. You don't have to actually spell out every single character you mean. You can just say capital A to capital Z, A dash Z, lowercase a to z, 0 to 9, and those are the typically the cases you would use them with is with the alphanumeric characters and with digits. The next three items the asterisk, the plus, and the question mark all have to do with how often element repeats. Does it occur zero or more times, one or more time, or zero or one time? So to take the first one as an example, file_name, that underscore may or may not exist.
If it's not there it still matches. If it exist one time it still matches. If it exists two times, three times, it doesn't matter. It still matches. Below those we have the alternation operator. This is the upright pipe that we've already seen we were piping commands. Notice that this is one of the symbols that has a meaning to Unix that's different than the meaning in regular expressions. Here it's the OR operator. So what it means is for example I asked for JPG or GIF or PNG. That's very common if you want all three file types to be matched.
Next we have the start and end of line anchors. The start of line anchor is the caret symbol. That's the same thing we used up on the negative character set, but it's in a different context here. Don't get them confused. If it's inside the square brackets, it's the negative characters set. Otherwise, we're really talking about this start of line anchor and that means that a line beginning with hello would match, but if hello was somewhere in the line, not at the beginning, it would not match. Same thing for the end of line anchor. If you need an actual literal character and you want to escape one of these regular expression characters, you would use the backslash and then there's a number of them at the bottom that I won't go over in detail, but they match either any digit, anything not a digit, anything that's an alphanumeric character or not, anything that's white space or not and so on.
Notice though that three of those I've marked with an asterisk. These are extended regular expression syntax. We'll talk more about that. But for now, just notice that there are a couple of these that are part of the extended set and some of them that are part of the basic set. There're also some predefined character classes that can help you to find certain types of things easier. The symbols for these are a little bit longer. All of them have square brackets and colons on either side of a keyword. So for example, alpha would match any of those alphabetic characters. Digit would match any numeric characters.
Alnum would match both, alphabetic or numeric, and so on. Now you could just as easily use those other symbols to write these out yourself. These just provide useful shortcuts. Notice here that the square bracket is not indicating a character set. This is talking about a single character. If you want to say this is the character set, we put another set of square brackets around that.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98223 Viewers
61 Video lessons · 85535 Viewers
71 Video lessons · 69488 Viewers
56 Video lessons · 101826 Viewers
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.
Your file was successfully uploaded.