From the course: Learning Regular Expressions

Unlock this course with a free trial

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

Multiple lookaround assertions

Multiple lookaround assertions

- [Instructor] So far in this chapter, we've been using only expressions with a single lookaround assertion. In this movie, we'll examine some techniques for using several assertions in one expression. Here's a regular expression that has two lookaround assertions. One is a positive lookahead, one is a negative lookahead. In order to understand what it does, let's break it down into a couple of parts. First, let's ignore those lookaround assertions and we'll see that what it's really doing is matching words that start with sea. That's one layer of what it's trying to do, and that's what it'll ultimately match. But we also have these assertions, and one of them asserts that there should be six or more characters. And the second one asserts that the word should not be seashore or seashores even. Thinking of them in layers like this, we realize that we can layer on more and more assertions, and each time we're narrowing down…

Contents