0% found this document useful (0 votes)
22 views1 page

Regex Cheatsheet

This document is a cheat sheet for Regular Expressions (Regex), detailing various patterns and their meanings. It provides examples of inputs that match each pattern, such as character classes, quantifiers, and lookaheads. The information is structured to serve as a quick reference for users working with Regex.

Uploaded by

Lalu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views1 page

Regex Cheatsheet

This document is a cheat sheet for Regular Expressions (Regex), detailing various patterns and their meanings. It provides examples of inputs that match each pattern, such as character classes, quantifiers, and lookaheads. The information is structured to serve as a quick reference for users working with Regex.

Uploaded by

Lalu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

■ Regex (Regular Expressions) Cheat Sheet

Pattern Meaning Example Input Matches

. Any character except newline cat, c@t, c t c.t → all three

^ Start of string Hello World ^Hello → match

$ End of string Hello World World$ → match

\d Digit (0–9) A1B2C3 \d → 1,2,3

\D Non-digit A1B2 \D → A,B

\w Word character (letters, digits, _) A1_B \w+ → A1_B

\W Non-word character Hi@2025 \W → @

\s Whitespace (space, tab, newline) Hi There \s → space

\S Non-whitespace Hi There \S+ → Hi, There

+ One or more aaa, a, b a+ → aaa, a

* Zero or more aaa, b a* → aaa, '', a

? Zero or one color, colour colou?r → both

{n} Exactly n times 2025 \d{4} → 2025

{m,n} Between m and n times 99, 1234 \d{2,4} → 99, 1234

[abc] One of a, b, or c bat, cat, dog [bc]at → bat, cat

[^abc] Not a, b, or c bat, hat, cat [^c]at → bat, hat

() Grouping abcabc (abc)+ → abcabc

| OR operator cat, dog cat|dog → matches either

(?=...) Lookahead (must contain) abc123 (?=\d) → digit check

(?!...) Negative lookahead abc123 (?!\d) → fails (digit present)

You might also like