From the course: Learning Regular Expressions

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Line breaks and multiline mode

Line breaks and multiline mode

- [Instructor] In this movie we'll continue our discussion of start and end anchors. By talking about a very important concept, line breaks and multiline mode. In the last movie, we saw that we can use our start and end anchors to indicate if a pattern should be at the start or end of a string. But you'll notice that in those meanings for each one of them, there's a little bit of a difference between the way they handle the end of a line. When you're matching a regular expression against multiple lines, it may not work quite the way that you think. Let's see the problem in action first. Here I have a list of groceries in my text and I just have a real simple regular expression that says it's a character set, including the letters A to Z, lowercase, a space repeated one or more times, and that matches everything that's in my list. Because I have the global flag set. Also, take note of the fact that I'm using the Perl…

Contents