Save this video free

Lecture 10: Regular expressions

Burton Ma · 46:35 · Watch on YouTube

Part of Queen's University CISC220. See all 23 lectures and search them

These notes were made with YouTube Collector. Paste any YouTube link and get the same: a summary, chapters and a searchable transcript.

Overview

Burton Ma introduces POSIX extended regular expressions in Bash as a way to search for text patterns and validate strings, emphasizing that regex metacharacters often differ from Bash glob syntax. He explains anchors, character classes, quantifiers, grouping, and alternation, then applies them with `grep -E` to search filenames, source code, HTML, and word lists.

Key takeaways

Chapters

0:00 Regular Expressions as a Language for Text Patterns
4:00 Bash String Conditions with the `=~` Operator
7:30 Literal Text and Case-Sensitive Matching
11:03 Anchors and the Dot Wildcard
16:17 Bracket Expressions, Ranges, and Literal Metacharacters
20:47 Regex Atoms and Quantifiers for Integers
27:17 Brace Quantifiers, Grouping, and Alternation
35:35 `grep -E` for Searching Files and Source Code
43:01 Searching HTML and Word Lists, and Using Regex with Restraint

Keep these chapters and the full searchable transcript in your own library.

Transcript excerpt

0:04 Okay, good morning everybody. Let's get started. >> Uh so if you look at the next notebook in the sequence, uh the next notebook in the sequence is actually the notebook called TR. Uh so TR is short for uh translate. Uh I'm going to skip over that notebook and come back to it um in the next lecture I think because the last question of your assignment um has you use something called a regular expression. So I think it's important that I show you how to uh work with regular expressions so that you can actually finish the assignment. All right. So what is a regular expression? So we'll start with a little quote here. Uh some people when confronted with a problem think I know I'll use regular expressions. Now they have two problems. Uh and so that's the

0:53 written by this um gentleman who runs this website called reax.info which not surprisingly is a website um that deals solely with regular expressions. So a regular expression um is like a mini language. Um so it lets you uh define uh it lets you define it's a language for defining patterns of text. um and they let you search text uh to see if that text contains something that matches um the given pattern. Now, we've seen some primitive pattern matching in bash, right? So, we've seen the star, the question mark, and the square brackets. Um regular expressions uh are much more sophisticated than bash's uh relatively primitive pattern matching.

1:43 Unfortunately, most regular expression um most versions of regular expressions use the same set of characters that bash uses for its glob patterns, right? So the star, the question mark, square brackets, these all have different meanings uh when you're talking about a regular expression. Uh so it's something you

This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.

In this course

Related notes

Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Burton Ma.

Want the full transcript?

Save this video in YouTube Collector to get its complete searchable transcript, your own AI summaries, and a library that keeps every video you collect in one place.