Capturing Groups to Search and Replace Text with Regular Expressions

preview_player
Показать описание
Searching and replacing text with regular expressions gives you the ability to sanitize and reformat data with more power and flexibility than you can otherwise. In this video you'll learn how to use capturing groups and the automatic variables they establish when searching and replacing with them. The difference between the automatic variable $0 and capturing group variables $1, $2, $3, and so on are discussed.

You are Encouraged to Follow Along! Here are the instructions to do so:
2. In VSCode, Go to View, then Command Palette, type Git: Clone and press enter
4. Select the Folder/Directory you would like to save the project, press ok. Open the project.
5. In the Files Explorer Pane in VS Code, you should now see the three .txt files we're using in the videos:

A Mysterious, Little Course on Regular Expressions

This is the fourth video in "A Mysterious, Little Course on Regular Expressions", a short introductory course on applied regular expressions. The first video introduced the "AND THEN" (concatenation) operator and gave instructions for setting up your computer with Visual Studio Code and the course's project repository with the same files used in the video. The second video introduced the "OR" operator (alternation / union). The third and previous video was on repetition using the quantifier/closure operator.

About me: Hey, hey! I'm Kris Jordan (he/him/his), a professor who teaches computer science at the University of North Carolina at Chapel Hill. Back when I first tried to learn regular expressions it felt like a lot of weird, cryptic incantations to memorize. I couldn't separate the essential concepts to understand from the merely convenient shorthand add-ons. When I was was taught their theoretical basis, I struggled to connect academic notation and abstract examples with real-world syntax and concrete applications. So I'm teaching this for you the way I wish regular expressions were introduced to me: fundamentals-first with the syntax of modern applications in an actively hands-on, follow-along style.

If you enjoy learning, or being refreshed on, useful applications of fundamental ideas in computer science, data science, and software engineering, I encourage you to Subscribe to my channel so you can follow along as new lessons are added on a variety of subjects you'll find valuable!
Рекомендации по теме
Комментарии
Автор

I found many videos on youtube about capturing group but this one is the best.

AshraRai
Автор

You are so amazing! The tutorial helps me understand a lot about Regular Expressions!

jhred
Автор

Wonderfully explained. I am not a programmer but I just understood about 90% of what you said.

hidgik
Автор

This was great, exactly the information I was looking for

TimmyJ
Автор

Very interesting video. I was looking for a way to search for specific letters and then replace each letter with a different letter. For example, to look for Ä Ö or Ü in a text, and replace them with A O or U. The main problem I have is how to do the replacing in one line instead of doing it one by one. Searching is easy, but replacing is not. Or so it seems. This video didn't offer an explanation for this issue, but I will keep watching for more content. Thank you!

eerofi
Автор

I just took COMP 116 this past spring and although I don't regret it (fell in love w Python), seeing these vids it's a shame that I didn't get to take 110 with you! Hopefully I'll have a chance to be in one of your classes later on.

claireliang
Автор

Great tutorial! Do you offer a full course on regular expressions on Udemy, Skillshare or any other similar platform? I would be interested. There seems to be a growing trend now among freelance translators to learn how to use regular expressions within CAT tools.

c.blouin
Автор

would ^([0-9]{0, 9})$ work for the first example?

MiMiBrokenbourgh
Автор

Unfortunately $0 didn't work for me on google sheets...

Yullenator
Автор

Just to note Atom (possibly other text editors) won't let you do $0 while replacing, so you gotta use $1 and parentheses.

ericschneider