Check out a free preview of the full Introduction to Bash, VIM & Regex course

The "Introducing Regular Expressions" Lesson is part of the full, Introduction to Bash, VIM & Regex course featured in this preview video. Here's what you'd learn in this lesson:

James introduces Regular Expressions (regex or regexp), which is special text string for describing a search pattern or a search and replace command.

Preview
Close

Transcript from the "Introducing Regular Expressions" Lesson

[00:00:00]
>> James Halliday: Let's learn now about regular expressions. So regular expressions are a pattern matching language, it's often used for different kinds of text processing problems that you might have. A lot of programming languages have built in support for regular expressions like JavaScript, Pearl, and Ruby. And like pretty much every program and language is gonna have at least a library that can do these regular expressions, so they're very widespread.

[00:00:35]
If you learn them, you can use them pretty much anywhere. The command line, programming language. But they're a little bit weird to look at, and they take some getting used to. But I think they're very powerful. I probably write regular expressions every single day. Even if I'm not really doing much on a computer, preferably at least a regex here and there, just because, once you know them and once you're kind of used to them, there's just so many places where you just need to fix some text a little bit.

[00:01:12]
And you can also use them from inside of VIM and other editors. So plenty of opportunities to use them once you can get to know them. So here's a few of those commands. We've already seen grep and sed, which are probably in your system. There's also, you can use perl or vim or less.

[00:01:30]
It's all places where you can find regexes. There are some annoying differences sometimes between the engines because in some of them you have to escape different meta characters in different ways. But,
>> James Halliday: In JavaScript, you can do all of these kinds of methods. That comma should be a closed paren.

[00:01:53]
Like splitting, so I could just show you what each of these looks like. So here if we have a string, and we wanna split on a regex. So I'll get into a moment, but \s means wide space. + means one or more. So we can

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now