Word Boundaries and Assertions
Pattern Matching - Lesson 2
18 min
Progress0/5
Word Boundaries (\b) Deep Dive
Concept
Word boundaries match positions between word characters (\w) and non-word characters. They don't consume characters, just mark positions.
Example
\bcat\b matches "cat" in "a cat runs" but not in "concatenate" \b\d+\b matches whole numbers, not digits within words
Practical Application
Essential for finding complete words, not just character sequences within larger words