Place * after a token to match it zero or more times. It is the most permissive repetition operator: the token may appear many times, once, or not at all. Shorthand for {0,}.
Remember
token* → zero or more of token
ab*c → ac, abc, abbbc (not abxc)
a* → "", "a", "aaa" all match
a+ → needs at least one a
* is greedy → match as many as possible
*? is lazy → match as few as possible
Attach * to the token that may repeat any number of times, including never.
Write the token you want to repeat (character, class, group, or metachar).
Add * right after it — e.g. b*, \s*, (ha)*.
Complete the rest of the pattern so the engine knows when to stop.
If empty must fail, switch to +. For a shorter match, use *?.
Piece
Required?
Role
Preceding token
Yes
What * repeats
* or *?
Yes
Zero-or-more; greedy vs lazy
Rest of pattern
Often
Gives the engine a stopping point
Pseudocode
Pseudocode
pattern = <token>* <rest>
// greedy *:
count = as many token matches as possible
while rest fails and count > 0:
count = count - 1 // backtrack
if rest succeeds (even with count = 0):
match
else:
fail
// lazy *? starts at count = 0 and grows only if needed
Reference
Cheat Sheet
Keep these facts handy while writing zero-or-more patterns.
Topic
Detail
Meaning
Zero or more of the previous token
Longhand
{0,}
Flexible middle
ab*c → ac, abc, abbbc
Whitespace trim
/^\s*/ and /\s*$/
Greedy / lazy
* max · *? min
vs +
* allows empty; + needs ≥ 1
Standard
ES3+ (universal)
Try it
Live Preview
Pick a pattern and a sample string to see whether * matches (and what match() returns).
Browser demo of the * quantifier — same idea as the examples below.
Result
pattern = /ab*c/
text = "ac"
test() → true
match() → ["ac"]
/* b* matched zero times */
Code
JavaScript Examples
Short, copy-ready snippets. Open DevTools Console, or use Try It Yourself for a live editor.
Example 1 — Flexible Middle with ab*c
Match a and c with any number of b characters between — including none.
The * quantifier is part of core JavaScript regex (ES3+). It works everywhere without polyfills.
✓ Baseline · ES3+
RegExp * quantifier
Supported in every modern and legacy browser, plus all Node.js versions. Universal syntax for zero-or-more repetition.
99%Universal syntax
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
*Excellent
Bottom line: Safe everywhere. Use * whenever zero repetitions of a token should still succeed.
Analysis
Performance Notes
Pattern style
Cost
Best for
token* (simple)
Usually linear
Whitespace, letters, clear delimiters
.* with anchors
Fine in practice
Short strings with a clear end marker
Nested * / ambiguous
Can explode
Avoid on untrusted input
Simple * patterns are fast. Trouble starts with nested or overlapping quantifiers that force heavy backtracking. Prefer specific classes (\s*, \d*) over open-ended .* when you can.
Remember
Key Takeaways
Role: match zero or more of the previous token.
vs +: use * when empty is valid; use + when you need at least one.
Greedy vs lazy:* takes the most; *? takes the least.
Scope:ab*c repeats only b — group with (ab)* when needed.
One line:* means “zero or more” — flexible, greedy by default, and too loose when you actually need +.
Frequently Asked Questions
The * quantifier means zero or more of the preceding token. For example, ab*c matches ac (zero b characters), abc, and abbbc. Unlike +, * allows the token to be skipped entirely.
Yes. * is shorthand for {0,}—the preceding item may repeat any number of times, including zero. Both are greedy by default in JavaScript.
+ requires at least one repetition. * allows zero. So /a+/ fails on an empty string, but /a*/ succeeds with a zero-width match at the start.
* is greedy—it matches as many characters as possible. *? is lazy—it matches as few as possible while still letting the rest of the pattern succeed.
Because * allows zero digits, the engine can match an empty string at many positions. Prefer \d+ when you need at least one digit, or filter empty strings from results.
The * quantifier is core JavaScript regex syntax since ES3. It works in every browser and Node.js version without polyfills.