Zero or more: log, log1, log2024
A regex exercise from Regexdrill. Solve it with a pattern box with live highlighting in your browser, checked against hidden test strings, and it is checked the moment you submit.
The task
The whole line must match. Match the word log followed by zero or more digits, so log, log1 and log2024 all match.
What this exercise teaches
log\d* takes the three letters and then as many digits as there are, including none. The plus sign would demand at least one digit and reject the plain word log.
A hint if you get stuck
The star means zero or more of the thing before it, so the digits may be missing altogether.
Try it now, free, no account needed
Every exercise on Regexdrill is free to try. Open it on the practice page, solve it, and get instant feedback with a hint. The worked solution opens once you solve it or after two tries.
Open this exerciseMore exercises in Basics
- Find a literal wordFree
- The dot matches one characterFree
- Character class: gray or greyFree
- Ranges: a letter and two digitsFree
- Negated class: no vowelsFree
- Counted repeats: 3 to 5 digitsFree
- One or more: goal, gooal, goooalFree
- Optional letter: color or colourFree
- Anchors: lines that start with ERRORFree
- Escaping: a price like $4.99Free
- Shorthand classes: a word, a space, a numberFree
- Anchors: lines that end with a periodFree
- Word boundaries: the whole word isFree
- The i flag: any capitalizationFree