liveBook · Manning

Word boundary

A word boundary is a position marking separation between words or a transition between word and non-word characters in text or a regular expression.

How 3 Manning books explain it

Data-Oriented Programming: Reduce software complexity

A word boundary is a position in text recognized by a regular expression as the boundary between a word character and a non-word character.

How it is used
Uses regular-expression boundaries to repair book-title searches involving case differences and prefixes beginning within multiword titles.
How deep it goes
Defines the boundary and demonstrates matching behavior, then stops short of explaining regular-expression engine internals.
Examples
Tests Habit, habit, 7 Habit, and habits of as matches, while abit, bit, 7 abit, and habit of return no books.
What you can do after
Apply it via a regular expression to implement and test case-insensitive prefix searches across word boundaries.

Read how Data-Oriented Programming: Reduce software complexity explains word boundary →

Regular Expression Puzzles and AI Coding Assistants

A word boundary is a regular-expression zero-width assertion that matches a position at the transition between word and non-word characters or at a string edge.

How it is used
Delimits complete lowercase words in regex searches that would otherwise match prefixes or internal fragments.
How deep it goes
Explains \b through a worked pattern and contrasts it with a more intricate lookaround construction.
Examples
Tests x-to-y matching against word lists, xyxyblah, and patterns generated by coding assistants.
What you can do after
Apply it via Python re patterns to select whole words while checking whether the chosen character class matches the intended word definition.

Read how Regular Expression Puzzles and AI Coding Assistants explains word boundary →

The Well-Grounded Rubyist, Fourth Edition

A word boundary anchor constrains a match to a transition between word and non-word characters or to a string boundary.

How it is used
Constrains regular-expression matches to word edges or string boundaries.
How deep it goes
Explains transitions, string edges, and the \b/\B contrast through a compact matching example.
Examples
Uses /\bword/ and /\Bword/ against “!word!sword” to contrast boundary and non-boundary matches.
What you can do after
Apply Ruby regular-expression anchors to distinguish standalone words from occurrences embedded in larger words.

Read how The Well-Grounded Rubyist, Fourth Edition explains word boundary →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.