1. Home
  2. Developer tools
  3. Regex Pattern Library

Regex Pattern Library

Start from a pattern that already handles the edge cases instead of writing an email or IP regex from scratch.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use Regex Pattern Library

  1. Search or pick a pattern.
  2. Try it on your own strings.
  3. Copy the pattern or the code for your language.

Features

  • 29 patterns in web, network, identifier, date, personal, text and code groups
  • Matching and non-matching examples for each
  • Code for JavaScript, Python, Go, Java, C# and PHP
  • Warning when Go’s RE2 cannot compile a pattern
  • Notes on what each pattern does not check

Supported formats

Input

  • Typed or pasted text

You get

  • Copied text

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the Regex Pattern Library is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Patterns check the shape of a value, not whether it exists (an email inbox, a postcode).

Guide

A library of tested regular expressions and how to use them safely

Regular expressions are compact, powerful and easy to get subtly wrong. Email, IP address, date and password checks are written again and again, and each rewrite risks letting bad values through or blocking good ones. This library collects 29 common patterns, each with examples that show what it accepts and rejects, and generates the code to use it in six languages.

What is in the library

Patterns are grouped by purpose. Web covers email addresses, URLs, domain names and URL slugs. Network has IPv4, IPv6, MAC addresses and port numbers. Identifiers include UUIDs, semantic versions and hex colours. Dates has ISO dates, RFC 3339 timestamps and 24-hour times. Personal covers phone numbers in E.164 form, US ZIP and UK postcodes, card number shapes, passwords and usernames. Text and Code add whitespace trimming, repeated words, HTML tags, decimal numbers, hashtags, JWTs, identifiers and file extensions.

Tested, not just collected

Every pattern carries a list of strings it must match and a list it must reject. The site’s test suite runs each pattern against its own list on every build, so a pattern cannot be edited into a broken state without a failing test. You can also type your own test strings, one per line, and see each marked as matching or not.

Anchors and flags

Validation patterns use ^ and $ so the entire value has to match; search patterns do not, because they look for pieces inside larger text. Flags change behaviour: i ignores case, g finds every match, m makes anchors work per line and u enables Unicode features such as \p{L}. The code generator carries them over: JavaScript keeps them after the closing slash, Python uses re.IGNORECASE, Java uses Pattern.CASE_INSENSITIVE, and C# uses RegexOptions.IgnoreCase.

Language differences

Most languages share the basics, but engines differ. Go’s regexp package uses RE2, which guarantees linear-time matching by leaving out lookahead, lookbehind and back-references, so patterns that need them, such as the domain-name and MAC address patterns, will not compile there and the page says so. JavaScript supports lookbehind in modern engines, PHP uses PCRE with delimiters, and C# verbatim strings double their quotes. The generated snippet handles escaping, so backslashes survive.

A worked example

Choose “IPv4 address”. The pattern limits each of four dot-separated octets to 0 through 255 without leading zeros. The built-in examples show 192.168.1.1 and 8.8.8.8 as matches and 256.1.1.1, 01.2.3.4 and 1.2.3 as rejections, so the list reads pass, pass, fail, fail, fail. Switching the language to Python produces re.compile(r"^(?:(?:25[0-5]… as a raw string.

What a regex cannot prove

A pattern checks shape, not truth. A valid-looking email may have no mailbox; a well-formed date such as 2026-02-31 does not exist; a phone number in the right format may not be assigned; a postcode may not be in use. Parse dates with a date library, confirm emails by sending a message and use a phone-number library for real validation. The password pattern checks composition only, and current guidance favours length and breach checks over character rules.

Performance and safety

Patterns with nested quantifiers can take exponential time on crafted input, known as ReDoS. The library avoids the common traps, but if you write your own, test long non-matching strings, set input length limits before matching, and prefer engines with linear-time guarantees for untrusted data.

  • Regex Tester tries your own patterns with explanations and match highlighting.
  • Redact Log Secrets applies detection patterns to mask sensitive data.
  • CSS to XPath covers another pattern language for documents.
  • Extract Emails pulls addresses out of text without writing a pattern.

Checked against the current version of the Regex Pattern Library on .

Frequently asked questions

Why do validation patterns start with ^ and end with $?

Without anchors, a pattern matches anywhere inside the text, so an email check would accept “not an email [email protected] junk”. The anchors force the whole string to fit. For searching text, as in the whitespace or hashtag patterns, they are left out.

What does the flag u or i change?

i ignores letter case, so HTTPS and https both match. u turns on Unicode mode in JavaScript, which makes classes like \p{L} work and treats characters outside the basic plane as single characters. g finds all matches instead of the first.

Is there a regex that validates every email address?

Not usefully. RFC 5322 allows forms such as quoted local parts that no real provider issues, and a regex cannot tell whether a mailbox exists. Use a practical pattern and confirm by sending an email.

Why does the same pattern behave differently in Go?

Go uses RE2, which guarantees linear-time matching by leaving out lookahead, lookbehind and back-references. Patterns that use them need rewriting or a check in code.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.