Anchors: lines that end with a period
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, so anchor the pattern yourself. Match lines whose last character is a period. A period followed by a space or anything else does not count.
What this exercise teaches
\.$ needs a literal period right before the end of the line. An unescaped dot would accept any last character, and without $ a period anywhere in the line would count.
A hint if you get stuck
$ outside brackets means the end of the line. The period is a special character, so escape it.
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. A free account adds the worked solution; Pro adds timed mode and the certificate.
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