Free tools Windows power users keep installed
One-click scans. No signup required.
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
A regular expression (regex) is a pattern for searching, matching, extracting, splitting, or replacing text. The core symbols are shared across many tools, but there is no single universal regex syntax: JavaScript, Python, Java, .NET, PCRE2, Go, and other engines differ in important details. Identify the engine your application uses before copying a pattern, and test it there.
Quick regex syntax reference
In the examples below, “common” means common across mainstream engines, not guaranteed identical everywhere. Unicode behavior, line endings, flags, and APIs can change the result.
Literals and escapes
| Syntax | Meaning | Example |
|---|---|---|
abc |
Literal text | cat matches “cat” |
|
Escape a metacharacter or introduce a special sequence | . matches a period |
\ |
Literal backslash in many flavors | Matches |
Common metacharacters are . ^ $ * + ? ( ) [ ] { } | . Escaping rules inside a character class differ from rules outside it; a literal hyphen, closing bracket, or caret may need special placement or escaping.
Keep regex syntax separate from the host language’s string syntax. The pattern d+ can be written as a JavaScript literal /d+/, a Python raw string r"d+", a Python or Java ordinary string "\d+", or a C# verbatim string @"d+". The string parser may process backslashes before the regex engine sees them. In Python, for example, b in an ordinary string can become a backspace rather than a regex word boundary. See the Python re documentation.
#1 Best Overall
Character classes
| Syntax | Meaning |
|---|---|
[abc] |
One character: a, b, or c |
[^abc] |
One character other than a, b, or c |
[a-z] |
One character in the a–z range, ordinarily ASCII |
[A-Z], [0-9] |
One uppercase ASCII letter; one ASCII digit |
[a-zA-Z0-9_] |
A common ASCII approximation of a word character |
[.] |
A literal period |
[abc&&[^b]] |
Class intersection in engines that support this syntax; not portable |
[a-z] is not a universal “any letter” class; it does not mean every alphabetic Unicode character. Examples: [aeiou] matches one lowercase vowel; [^,s]+ matches one or more non-comma, non-whitespace characters; [0-9A-Fa-f]{2} matches two ASCII hexadecimal characters.
Predefined classes and Unicode
| Syntax | Common meaning | Caveat |
|---|---|---|
d / D |
Digit / non-digit | Unicode versus ASCII definition varies |
w / W |
Word character / non-word character | Definition varies; often includes digits and underscore |
s / S |
Whitespace / non-whitespace | Exact whitespace set varies |
. |
Any character other than line terminators by default | Dotall/singleline mode changes this |
Do not assume d, w, s, or b mean the same thing in every engine. Python’s Unicode string patterns use Unicode matching by default, while its ASCII flag narrows certain classes and boundaries; bytes patterns differ. JavaScript has its own rules, and Unicode property escapes such as p{Letter} require appropriate Unicode-aware syntax. Consult the MDN JavaScript regex cheat sheet and the relevant engine documentation.
Where supported, p{L} or p{Letter} matches a Unicode letter; p{Script=Greek} selects Greek-script characters; and P{L} matches a character that is not a letter. Property names and support differ by flavor.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallAnchors and boundaries
| Syntax | Common meaning |
|---|---|
^ / $ |
Start / end of input, or line boundaries in multiline mode |
A |
Absolute start in flavors that support it |
Z / z |
End anchors with flavor-specific newline rules; z is strict absolute end where supported |
b / B |
Word boundary / not a word boundary, based on the engine’s word-character rules |
G |
Previous match position in flavors that support it |
^cat$ is often used to describe an input consisting only of “cat,” but newline and multiline behavior can affect that assumption. For full-string validation, prefer a full-match API when available. Python offers re.fullmatch(); .NET matching APIs can find a substring unless the pattern or operation requires the whole input. See the Python API documentation and .NET regex behavior notes.
Rank #2
bcatb finds “cat” as a whole word under the engine’s boundary rules, not inside “scatter.” Those rules can be surprising with accented or non-Latin text, apostrophes, hyphens, underscores, emoji, and combining marks.
Quantifiers
| Syntax | Meaning |
|---|---|
* / + / ? |
Zero or more / one or more / zero or one |
{n} |
Exactly n repetitions |
{n,} |
At least n repetitions |
{n,m} |
Between n and m repetitions |
*?, +?, {n,m}? |
Lazy versions in common flavors: try the least amount first |
++, *+ |
Possessive repetition in flavors that support it |
For example, d{4} matches four digits and colou?r matches “color” or “colour.” Greedy quantifiers try to consume as much as possible; lazy ones try less first. Lazy does not mean safe or necessarily correct. Possessive quantifiers and atomic groups prevent backtracking in supported flavors, but are not portable. PCRE2 documents these features in its syntax reference.
Alternation, groups, and captures
| Syntax | Meaning |
|---|---|
a|b |
Match a or b |
(abc) |
Group and capture text |
(?:abc) |
Group without capturing |
1 |
Backreference to capture group 1 |
(?<name>abc) |
Named group in JavaScript, .NET, and several other flavors |
(?P<name>abc) |
Python named-group syntax |
k<name> / (?P=name) |
Named backreference forms used by different flavors |
Alternation has precedence implications: cat|dog means either alternative, while gr(a|e)y matches “gray” or “grey.” The pattern ^cat|dog$ does not generally anchor both choices. Use ^(?:cat|dog)$ for that intent.
Recommended Free Tools
(d{4})-(d{2})-(d{2}) captures the year, month, and day. A duplicated-word pattern such as b(w+)s+1b uses a backreference, with results dependent on the engine’s definition of word characters. Group numbers follow opening-parenthesis order; adding a capture early can shift later numbers. Use (?:...) for structural grouping when you do not need the captured text.
Rank #3
Lookarounds and assertions
| Syntax | Meaning |
|---|---|
(?=...) |
Positive lookahead: next text must match |
(?!...) |
Negative lookahead: next text must not match |
(?<=...) |
Positive lookbehind: preceding text must match |
(?<!...) |
Negative lookbehind: preceding text must not match |
Assertions check a position without consuming the asserted text. For example, d+(?= dollars) matches digits only when “ dollars” follows. ^(?!.*badminb).+$ rejects a line containing the whole word “admin,” subject to the flavor’s boundary rules. Lookbehind availability and restrictions vary: some engines require fixed-length expressions, some permit more, and older runtimes may not support it. See MDN’s assertions reference and Python’s lookaround documentation.
Flags and modes
| Flag | Common meaning | Note |
|---|---|---|
i |
Case-insensitive | Unicode case behavior varies |
m |
Multiline anchors | Typically changes ^ and $ |
s |
Dot matches line terminators | Often called dotall or singleline |
g, y |
Global / sticky matching in JavaScript | Can affect stateful methods and lastIndex |
u, v |
Unicode-aware JavaScript modes | v adds character-set capabilities |
d |
Match indices in JavaScript | JavaScript-specific |
x |
Free-spacing/comments mode in many flavors | Not universal |
Flags are not universal. JavaScript can write /hello/gi. Python uses constants such as re.IGNORECASE, re.MULTILINE, re.DOTALL, re.VERBOSE, and re.ASCII. Python’s Unicode flag is redundant for Unicode str patterns. Check your engine’s documentation before translating flags.
Useful patterns for common tasks
These are starting points, not universal validators. Test both expected matches and non-matches in the target engine.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
| Task | Pattern | What it does and does not establish |
|---|---|---|
| Digits | d+ |
One or more digits, with engine-dependent Unicode behavior |
| Signed integer | [+-]?d+ |
Optional sign followed by digits |
| Decimal with optional exponent | [+-]?(?:d+(?:.d*)?|.d+)(?:[eE][+-]?d+)? |
Basic decimal notation; not locale-aware |
| Whitespace run | s+ |
One or more engine-defined whitespace characters |
| Trim-edge spaces/tabs | ^[ t]+|[ t]+$ |
Finds leading or trailing spaces/tabs; use a built-in trim function for ordinary trimming |
| US ZIP format | ^d{5}(?:-d{4})?$ |
Five digits, optionally hyphen and four digits; does not establish assignment or existence |
| ISO-like date shape | ^d{4}-d{2}-d{2}$ |
Checks YYYY-MM-DD shape only |
| Basic date ranges | ^d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]d|3[01])$ |
Constrains month/day ranges but not month lengths or leap years |
| Basic email shape | ^[^@s]+@[^@s]+.[^@s]+$ |
A simple UI check, not full standards validation or delivery verification |
| Illustrative HTTP(S) shape | ^https?://[^s]+$ |
Not a complete URL validator |
| Simple quoted text | "[^"rn]*" |
Double-quoted, single-line text without embedded quotes |
| Quoted text with backslash escapes | "(?:\.|[^"\rn])*" |
Illustrative; escape rules depend on the format |
| Text inside square brackets | [([^]]*)] |
Captures through the next closing bracket; does not handle arbitrary nesting |
| Split comma-separated values with optional spaces | s*,s* |
Useful delimiter for simple input; quoted commas require a CSV parser |
A date-shaped value can still be impossible, such as February 31. Parse dates and numbers with the relevant language and locale rules after any structural check. The same principle applies to email and URLs: use an appropriate parser or application-level validation, and verify email ownership by sending a message when it matters. For URLs, validate permitted schemes and hosts as required by the application; do not rely on a giant regex for security-sensitive decisions.
Rank #4
- Used Book in Good Condition
For text between delimiters, a constrained class such as <[^>]*> avoids the broad overmatch of <.*>, but neither is a substitute for an HTML or XML parser. Nested structures may require a parser or flavor-specific recursion. PCRE2 documents its nonportable advanced constructs in the pattern reference.
Replacement syntax
Replacement strings are more flavor- and API-specific than match patterns. Common concepts include the full match, numbered captures, named captures, and sometimes text before or after the match; the token spelling differs. Do not copy a replacement expression between languages without checking it.
JavaScript date reordering:
"2026-08-18".replace(/(d{4})-(d{2})-(d{2})/, "$2/$3/$1");
Python date reordering:
re.sub(r"(d{4})-(d{2})-(d{2})", r"2/3/1", text)
Use a replacement function or callback when the output depends on the captured value. JavaScript, Python, .NET, and Java have different replacement conventions; consult the API documentation for the exact method you call.
Flavor differences: what to check
The following are broad orientation points, not a complete compatibility guarantee. Runtime versions and options matter.
Best Value
- Used Book in Good Condition
| Engine or family | Useful distinction |
|---|---|
| JavaScript | Regex literals use /pattern/flags; RegExp strings need host-language escaping. Named groups use (?<name>...); flags include JavaScript-specific g, y, d, u, and v. |
Python re |
Offers search, match, fullmatch, findall, finditer, sub, and split. Named groups use (?P<name>...). The third-party regex package is not the same engine. |
| PCRE2 | Perl-compatible engine with many advanced features, including constructs that other flavors omit. Check the actual PCRE2 version and options. |
| .NET | Has its own options, APIs, character classes, and backtracking behavior; it also offers a non-backtracking option in supported runtimes. Check the target .NET version and API. |
| Java | Pattern compiles expressions and Matcher provides operations such as find() and matches(). Java source strings generally need doubled backslashes. |
| Go / RE2-style engines | Some engines deliberately omit constructs such as backreferences or lookaround to keep matching behavior predictable. Do not assume a pattern from PCRE2 will compile. |
| Rust regex crate | Its supported syntax and API are specific to the crate; confirm them rather than assuming Perl-compatible behavior. |
Features that commonly fail to port include Unicode properties, named-group and named-backreference syntax, lookbehind, atomic groups, possessive quantifiers, conditionals, recursion, class intersection/subtraction, inline modifiers, free-spacing mode, and replacement tokens. Even basic constructs can differ in Unicode interpretation and newline handling. For authoritative details, see the MDN JavaScript regex guide, Python documentation, PCRE2 syntax, .NET quick reference, and the Java Pattern API. The cited Java API is for Java 26; do not infer identical behavior for every JDK version.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Using regex in common languages
JavaScript
const re = /d+/;
const re2 = new RegExp("\d+", "g");
re.test("Room 42"); // true
"Room 42".match(re); // first match
"Room 42".replace(re, "X"); // "Room X"
A slash inside a regex literal must be escaped. With the g flag, methods such as match and exec have different repeated-match behavior, and regex objects can carry state through lastIndex. The y flag is sticky: matching must begin at the current position. See MDN’s RegExp reference.
Python
import re
pattern = re.compile(r"d+")
match = pattern.search("Room 42")
re.search(r"d+", text) # find anywhere
re.match(r"d+", text) # try at the beginning
re.fullmatch(r"d+", text) # require the entire string
re.findall(r"d+", text) # return matches
re.finditer(r"d+", text) # return match objects
re.sub(r"d+", "X", text) # replace
re.split(r"s*,s*", text) # split
findall() returns strings or tuples depending on capturing groups. Use finditer() when match objects and positions are useful. Raw strings reduce escaping but do not change regex rules.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →.NET and C#
using System.Text.RegularExpressions;
var pattern = @"bd{5}(?:-d{4})?b";
Match match = Regex.Match(input, pattern);
bool found = Regex.IsMatch(input, pattern);
string output = Regex.Replace(input, pattern, replacement);
Options include IgnoreCase, Multiline, Singleline, ExplicitCapture, IgnorePatternWhitespace, CultureInvariant, and—depending on runtime—NonBacktracking. For patterns applied to untrusted or potentially long input, consider a match timeout, input limits, and the engine options available in your target runtime. Microsoft explains .NET backtracking and regex behavior.
Java
Pattern pattern = Pattern.compile("\d+");
Matcher matcher = pattern.matcher("Room 42");
if (matcher.find()) {
String digits = matcher.group();
}
boolean entireRegionMatches = matcher.matches();
find() searches for a matching subsequence; matches() attempts to match the whole matcher region. Java source strings generally double backslashes. Verify named-group details and other features against the JDK version in use; the Java 26 Pattern documentation describes that version’s API.
How to test a regex reliably
- Identify the production engine and version. “Regex” alone is not enough; note the language, library, options, and API.
- Choose the exact flavor in a tester. regex101 documents multiple flavors, but a tester is useful only if its selected flavor and options match your application. Its documentation describes supported flavors.
- Test positive and negative cases. Include valid examples, near misses, empty input, boundaries, and malformed input.
- Inspect captures and positions. Confirm group numbering, named captures, and the exact substring returned by the API.
- Test replacement output separately. A correct match pattern does not guarantee correct replacement syntax.
- Test line endings and Unicode if relevant. Include newlines, accented text, non-Latin scripts, combining marks, and the exact input encoding.
- Test long and adversarial inputs. This matters especially for backtracking engines and untrusted input.
- Run the final tests in the production runtime. A web tester cannot substitute for the actual engine and API.
Common mistakes and safer fixes
- Testing the wrong flavor: a pattern accepted by a PCRE2 tester may fail in JavaScript or a restricted engine. Select the target flavor and verify in the application.
- Double-escaping or under-escaping: check what the host-language string passes to the engine; prefer Python raw strings or C# verbatim strings where appropriate.
- Assuming dot includes newlines: it usually does not by default. Use the correct mode or a deliberately chosen character class.
- Assuming anchors always mean whole input: multiline options and final-newline behavior can change results. Prefer a full-match operation when available.
- Treating
was “all letters”: it often includes digits and underscore, and Unicode coverage varies. Use explicit properties or language-specific validation when appropriate. - Relying on lazy quantifiers to fix a broad pattern:
<.*?>may reduce an overlong match, but it does not parse HTML or handle nested structure. Constrain the character set or use a parser. - Using capturing groups for structure only: unnecessary captures can change match arrays and numbering. Prefer
(?:...). - Validating semantics with shape alone: a date, email, URL, or ZIP-shaped string is not necessarily valid, deliverable, safe, or assigned. Use the proper parser or verification step.
- Ignoring catastrophic backtracking: nested ambiguous repetitions such as
(a+)+$can trigger very slow behavior on crafted input in backtracking engines. Simplify ambiguous alternatives, use supported atomic or possessive constructs where appropriate, set timeouts, cap input length, and consider a linear-time engine.
Regex is a good fit for many flat text patterns, extraction tasks, and simple structural checks. Prefer dedicated parsers for JSON, XML/HTML, programming languages, nested expressions, quoted CSV, locale-aware dates and numbers, and complex URL semantics. Parsing and semantic validation are different jobs from recognizing a text shape.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →

