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.

Challenge: Lookaround assertions

Challenge: Lookaround assertions - Regular Expressions Tutorial

From the course: Learning Regular Expressions

Challenge: Lookaround assertions

(upbeat music) - [Instructor] It's time for another challenge assignment. This challenge will use what you've learned about look around assertions. This challenge will use the file us_presidents.csv from the exercise files. Try to write a regular expression which will match the whole line for every U.S. president in the list. There should be 46 matches. That's every line except for the header. Then use that as the starting point for several other expressions. Write a regular expression to find presidents whose home state was not Virginia or Massachusetts. There should be 37. Then write a different regular expression to find every president with a last name longer than seven characters. There should be 15. Write a different regular expression to find presidents whose names do not have a middle initial. There should be 29. And then write another expression to match only presidents whose term in office began on or…

Contents