Here is the video version for this topic. You can read the written version which comes after the video section.

When talking about Regex patterns, there are a some terms you’d hear a lot and it’s important to understand them. Let’s look at them:

A string is a combination of characters which you apply a regular expression to. A string can be a letter, like “a”; it can be a word like “javascript” or it can be a sentence like “I bought 2 shoes for $5 from the market”. When you apply a pattern on a string, you can get the parts of that string (which we can call substrings) that match.

Digits refers to numbers, which are 0 1 2 3 4 5 6 7 8 and 9.

Or you can also call them alphabets, which refers to A B C to Z

Letters can be of different cases. You can have uppercase A B C and lowercase a b c.

A symbol is a character, which you can call a sign. These are not letters or digits. They are characters that can have special meanings. For examples:

  • the dollar $ sign
  • the period . sign
  • the plus + sign
  • the exclamation ! sign
  • the backward slash \ sign
  • and many more…

There are so many symbol characters, and as we will see in this course, some of these characters can perform special functions in regex patterns.

A whitespace is a character, or you can call it a space, which refers to a vertical or horizontal space.

For the horizontal space:

You have the single space which is the space between these words in “Hello world”

You also have the tab space which is longer than a single space. You can see it between these words in “Hello world”

For the vertical space:

You have the newline character which is the space between one line and another. For example

Hello
World

This can also be called a line break.

When you see “character”, it means digits, or letters, or symbols or whitespaces. A string can be made up of one or more characters.

This refers to a regular expression, which can match a combination of characters. A pattern can be as simple as, for example, a number, followed by string, followed by number. Or it can be a symbol, followed by 4 letter words, then a space, and one letter.

Regular Expression patterns have some behaviours by default. Flags are optional characters you can add to the end of your pattern to change some of those default behaviours.

If you don’t understand what I’m saying now, do not worry. We'll look at flags in the flags lesson .


Now, let’s move on to learning how to create a regex pattern .