Word boundaries: the whole word is
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 is as a whole word. The letters is inside a longer word, as in this or island, do not count.
What this exercise teaches
\bis\b only matches is when no letter, digit or underscore touches it on either side. \b takes up no characters: it is a position, like ^ and $.
A hint if you get stuck
\b matches the position between a word character and a non-word character, or the start or end of the line. Put one on each side of the word.
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
- The i flag: any capitalizationFree