Regexdrill

Level 1: Basics Exercise 11 of 70 Free

Shorthand classes: a word, a space, a number

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 one word made of letters, digits or underscores, then exactly one space, then one or more digits, like item 42.

What this exercise teaches

\w+ \d+ takes a run of word characters, one literal space and a run of digits. Because the whole line must match, a second word, a hyphen or a second space makes the line fail.

A hint if you get stuck

\w is any word character (a letter, digit or underscore) and \d is any digit. Repeat each with +.

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 exercise

More exercises in Basics