Regexdrill

Level 1: Basics Exercise 15 of 88 Free

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 exercise

More exercises in Basics