The i flag: any capitalization
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
A match anywhere counts. Match lines that contain the text error in any mix of upper and lower case, such as Error, ERROR or eRRor. Set the i flag.
What this exercise teaches
With the i flag, error matches every capitalization of those five letters. Listing the variants by hand, as in Error|ERROR|error, always misses some.
A hint if you get stuck
Flags change how the whole pattern behaves. The i flag makes letters match in both cases, so the pattern itself can stay in lowercase.
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
- Zero or more: log, log1, log2024Free
- 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