General | Regular Expressions | Codecademy (2024)

^Matches the start of text, or the start of a line, depending on the settings of the regex engine.^a only matches the first “a” in “a match is made”$Matches the end of text, or the end of a line, depending on the settings of the regex engine.!$ only matches the second “!” in “Hello! World!”.Matches any one character.. matches “c”, “a” and “t” in “cat”*Matches the preceding element zero or more times.co*t matches “ct”, “cot” and “coot”+Matches the preceding element one or more times.co+t matches “cot”, “coot” but not “ct”?Matches the preceding element zero or one time.co?t matches “ct”, “cot” but not “coot”{n}Matches the preceding element exactly n times.co{2}t matches “coot” but not “cot” or “cooot”{,max}Matches the preceding element zero to max times.co{,2]t matches “ct”, “cot”, “coot” but not “cooot”{min,}Matches the preceding element min or more times.co{2,}t matches “coot” and “cooot” but not “cot”{m,n}Matches the preceding element at least m and not more than n times.co{2,3}t matches “coot” and “cooot” but not “cot”[ ]Matches the characters inside the brackets. Can also specify ranges of characters such as [a-z].[bcm]at matches “cat”, “bat” and “mat”[^ ]Matches characters not inside the brackets. Can also specify ranges of characters such as [^a-z].b[^a]t matches “bit”, “bot”, and “but” but not “bat”|Matches the pattern on the right of the | or the pattern on the left.yes|no matches both “yes” and “no”( )Groups a pattern together and marks it for future reference(ca|bi)t matches “cat” and “bit”\wMatches alphanumeric characters and “_“.\w+ matches “Hello” and “World” in “Hello World!”\WMatches non-word characters.\W matches the space and “!” in “Hello World!”\bMatches word boundaries.o\b matches the first “o” in “Hello World!”\BMatches non-word boundaries.o\B matches the second “o” in “Hello World!”\dMatches a digit character.\d+ matches “123” in “abc123”\DMatches a non-digit character.\D+ matches “abc” in “abc123”\sMatches a whitespace character.\s matches the space in “Hello World!”\SMatches a non-whitespace character.\S+ matches “Hello” and “World!” in “Hello World!”
General | Regular Expressions | Codecademy (2024)
Top Articles
Latest Posts
Article information

Author: Lilliana Bartoletti

Last Updated:

Views: 5948

Rating: 4.2 / 5 (53 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Lilliana Bartoletti

Birthday: 1999-11-18

Address: 58866 Tricia Spurs, North Melvinberg, HI 91346-3774

Phone: +50616620367928

Job: Real-Estate Liaison

Hobby: Graffiti, Astronomy, Handball, Magic, Origami, Fashion, Foreign language learning

Introduction: My name is Lilliana Bartoletti, I am a adventurous, pleasant, shiny, beautiful, handsome, zealous, tasty person who loves writing and wants to share my knowledge and understanding with you.