Skip to content

Latest commit

Β 

History

History
23 lines (18 loc) Β· 965 Bytes

basics.mdx

File metadata and controls

23 lines (18 loc) Β· 965 Bytes

Basics

Regular expressions are typically formatted as /<rules>/<flags>. Often people will drop the slashes and the flags for brevity. We'll get into the details of flags in a later chapter, but the one you need to know now is g, which stands for "global".

Let's start with the regex /p/g.

pancake pineapple apple mango Plum

As we can see, /p/g matches all lowercase p characters. Note that regexes are case sensitive by default. If the regex has one or more "matches" within the input string, it is said to "match" the regex. Think of "the matches" as an array, and whether an input "matches" a regex as a boolean.

apple pineapple happiness sipping apple juice papaya