⚡
usefultools.dev
.*

Regex-Spickzettel

NEU

Spickzettel für reguläre Ausdrücke mit Ankern, Klassen, Quantifizierern, Gruppen, Lookaround, Flags und fertigen Mustern, mit JavaScript-Hinweisen. Mit Suchfilter und Kopieren per Klick. Die Syntax wird auf Englisch angezeigt.

Läuft zu 100 % in deinem Browser — deine Eingaben werden nie hochgeladen oder auf unseren Servern gespeichert.

79 Einträge in 9 Abschnitten

Anchors & boundaries

  • ^

    Start of the string (start of each line with the m flag).

  • $

    End of the string (end of each line with the m flag).

  • \b

    Word boundary: between a word character and a non-word character.

  • \B

    Not a word boundary.

  • \A

    Start of the whole string. Not in JavaScript; use ^ without the m flag.

  • \z

    End of the whole string. Not in JavaScript; use $ without the m flag.

Character classes

  • .

    Any character except a line break (with the s flag, including line breaks).

  • \d

    A digit, same as [0-9] in most flavors.

  • \D

    Any character that is not a digit.

  • \w

    A word character: letter, digit or underscore (ASCII only in JavaScript).

  • \W

    Any character that is not a word character.

  • \s

    Whitespace: space, tab, line break and similar.

  • \S

    Any character that is not whitespace.

  • [abc]

    One of the listed characters: a, b or c.

  • [^abc]

    Any character except a, b and c.

  • [a-z]

    One character in a range, here lowercase a to z.

  • [a-zA-Z0-9]

    Several ranges in one class: ASCII letters and digits.

  • [\s\S]

    Any character including line breaks, a trick that works without the s flag.

Quantifiers

A quantifier applies to the item right before it.

  • *

    Zero or more times (greedy).

  • +

    One or more times (greedy).

  • ?

    Zero or one time: makes the item optional.

  • {3}

    Exactly 3 times.

  • {2,}

    2 or more times.

  • {2,5}

    Between 2 and 5 times.

  • *?

    Lazy: zero or more times, as few as possible.

  • +?

    Lazy: one or more times, as few as possible.

  • {2,5}?

    Lazy range: as few repetitions as possible within 2 to 5.

  • a++

    Possessive quantifier: no backtracking. Supported in PCRE, Java and others, not in JavaScript.

Groups & backreferences

  • (abc)

    Capturing group: groups the pattern and remembers the match.

  • (?:abc)

    Non-capturing group: groups without remembering.

  • a|b

    Alternation: match a or b.

  • (cat|dog)s?

    Group an alternation, then make the "s" optional.

  • \1

    Backreference: the same text matched by capturing group 1.

  • (\w)\1

    Two identical word characters in a row, such as "ll".

  • (?<year>\d{4})

    Named capturing group (JavaScript, .NET, PCRE).

  • \k<year>

    Backreference to a named group in JavaScript.

  • (?P<year>\d{4})

    Named group syntax used by Python (and PCRE).

Lookaround

Lookarounds check the surroundings without including them in the match.

  • a(?=b)

    Positive lookahead: "a" only when followed by "b".

  • a(?!b)

    Negative lookahead: "a" only when not followed by "b".

  • (?<=\$)\d+

    Positive lookbehind: digits that come right after a $ sign.

  • (?<!\$)\b\d+

    Negative lookbehind: digits not preceded by a $ sign.

  • ^(?=.*\d)(?=.*[a-z]).{8,}$

    Password-style check: at least 8 characters with a digit and a lowercase letter.

Flags

Written after the closing slash in JavaScript, e.g. /abc/gi.

  • g

    Global: find all matches instead of stopping at the first.

  • i

    Ignore case.

  • m

    Multiline: ^ and $ match at each line.

  • s

    Dot-all: . also matches line breaks.

  • u

    Unicode: treat the pattern as code points and enable \p{...}.

  • y

    Sticky (JavaScript): match only at lastIndex.

  • d

    Indices (JavaScript): add start and end positions of each group to the result.

  • (?i)

    Inline flag at the start of a pattern, used in Python, PCRE and Java. JavaScript does not support it.

Escapes & special characters

These characters have a special meaning and need a backslash to match literally: \ ^ $ . | ? * + ( ) [ ] { }

  • \.

    A literal dot.

  • \\

    A literal backslash.

  • \/

    A literal slash (needed inside /.../ literals in JavaScript).

  • \n

    Line feed (new line).

  • \r

    Carriage return.

  • \t

    Tab.

  • \x41

    A character by its two-digit hex code, here "A".

  • \u00e9

    A character by its four-digit Unicode code, here "é".

  • \p{L}

    Any Unicode letter (needs the u flag in JavaScript).

  • \p{Lu}

    Any uppercase Unicode letter (needs the u flag in JavaScript).

Common patterns

Starting points, not full validators. Always test with your own data.

  • ^[^\s@]+@[^\s@]+\.[^\s@]+$

    Email, loose check: [email protected]. The full email standard is far wider, so confirm by sending a message.

  • https?:\/\/[^\s/$.?#].[^\s]*

    Web URL with http or https, simple version. Misses other schemes and some valid edge cases.

  • ^(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)$

    IPv4 address with each part from 0 to 255. Does not say whether the address is reachable.

  • ^\d{4}-\d{2}-\d{2}$

    Date shaped like 2026-11-23. Checks the layout only, so 2026-99-99 also passes.

  • ^([01]\d|2[0-3]):[0-5]\d$

    Time in 24-hour HH:MM format.

  • ^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$

    Hex color such as #fff or #1a2b3c, with optional #.

  • ^[a-z0-9]+(?:-[a-z0-9]+)*$

    URL slug: lowercase words joined by single hyphens.

  • ^\+?[0-9\s().-]{7,15}$

    Loose phone number check. Phone formats differ by country, so treat it as a rough filter.

  • ^\s+|\s+$

    Leading and trailing whitespace, handy for trimming with a replace.

  • \s{2,}

    Two or more whitespace characters in a row, to collapse into a single space.

JavaScript notes

  • /pattern/flags

    Regex literal syntax. Same as new RegExp("pattern", "flags").

  • regex.test(str)

    Returns true or false. With g or y, it moves lastIndex between calls.

  • str.match(regex)

    First match with groups, or all matches as an array when g is set.

  • str.matchAll(/(\d+)/g)

    Iterator of every match including groups. The regex must have the g flag.

  • str.replace(/(\w+) (\w+)/, "$2 $1")

    Replace using $1, $2 for capture groups, here swapping two words.

  • str.replaceAll(/a/g, "b")

    Replace every match. A regex argument must have the g flag.

  • const { groups } = /(?<y>\d{4})-(?<m>\d{2})/.exec(str)

    Read named groups from the groups object: groups.y and groups.m.

  • str.replace(re, "$<y>")

    Use a named group in a replacement string.

  • new RegExp(escapedText, "g")

    Build a pattern from a string. Escape user text first, since it may contain special characters.

⚡

Schnelle Beispiele

Typische Eingaben und die Ergebnisse, die dieses Tool liefert.

Klasse
Beliebiger Unicode-Buchstabe (u-Flag)
\p{L}
Lookbehind
Ziffern nach einem $-Zeichen
(?<=\$)\d+
Muster
Datum im Format 2026-11-23
^\d{4}-\d{2}-\d{2}$
Gruppe
Benannte Gruppe für ein Jahr
(?<year>\d{4})
📖

Überblick

Reguläre Ausdrücke beschreiben Textmuster in einer kompakten Syntax, die man leicht vergisst. Dieser Regex-Spickzettel behandelt Anker, Zeichenklassen, Quantifizierer, Gruppen und Rückverweise, Lookaround, Flags und Escapes sowie Ausgangsmuster für E-Mail, URL, IPv4-Adresse, Datum und Uhrzeit.

Die Syntax unterscheidet sich je nach Variante etwas, deshalb nennen die Einträge, wo sich JavaScript, Python oder PCRE anders verhalten, und ein JavaScript-Abschnitt behandelt benannte Gruppen, matchAll sowie die Flags sticky und unicode. Die gängigen Muster sind Ausgangspunkte mit ehrlichen Einschränkungen, keine vollständigen Validatoren.

Syntax, Muster und ihre kurzen Beschreibungen werden auf Englisch angezeigt; übersetzt sind nur die Oberfläche und der Seitentext. Filtere die Liste, kopiere ein Muster und probiere es mit deinem eigenen Text im Regex-Tester aus. Alles bleibt in deinem Browser.

Warum dieses Tool?

  • Regex-Syntax nachschlagen, ohne die Seite zu verlassen
  • Hinweise zu Unterschieden zwischen JavaScript und Python
  • Gängige Muster mit ehrlichen Grenzen
  • Nach Symbol oder Stichwort filtern
  • Jedes Muster mit einem Klick kopieren
⭐

Funktionen

⚓

Anker und Klassen

Grenzen, Ziffern, Wortzeichen, Bereiche und negierte Mengen.

🔁

Quantifizierer

Gierige, genügsame und possessive Wiederholung, mit den Varianten, die sie unterstützen.

👀

Lookaround

Beispiele für Lookahead und Lookbehind, darunter eine Prüfung im Stil von Passwortregeln.

🧪

Gängige Muster

E-Mail, URL, IPv4, Datum, Uhrzeit, Hex-Farbe und Slug, jeweils mit einem Vorbehalt.

🟨

JavaScript-Hinweise

test, match, matchAll, replaceAll und benannte Gruppen im Code.

📋

Kopieren pro Muster

Jede Zeile hat eine Schaltfläche „Kopieren“ für den genauen Text.

🛠️

So funktioniert’s

1

Abschnitt wählen

Scrolle zu Quantifiers, Lookaround, Flags oder einer anderen Gruppe (die Abschnittstitel sind auf Englisch).

2

Oder filtern

Tippe ein Symbol oder Wort wie „lazy“ oder „email“ in das Filterfeld.

3

Hinweis lesen

Lies die Beschreibung auf Englisch auf Unterschiede zwischen den Varianten, bevor du kopierst.

4

Ausprobieren

Klicke auf Kopieren und füge das Muster mit deinem eigenen Text in den Regex-Tester ein.

🤔

Häufig gestellte Fragen