liveBook · Manning

Prefix matching

As explained in Data-Oriented Programming: Reduce software complexity

Prefix matching is text matching that succeeds when a specified string begins at a recognized word boundary or other defined starting position.

A search for “habit” should find “7 Habits of Highly Effective People,” while “abit” should not. Prefix matching handles this by checking whether a prefix begins at a word boundary, not merely whether the whole title starts with it. section 15.4

Case-insensitive word-prefix matching

Lowercase both sentence and prefix, then build a regular expression from the prefix: \\b matches a word boundary. Thus \\bHabits and \\b7 Habits match “7 Habits of Highly Effective People,” while “abits” does not. section 15.4

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Defines boundaries, case normalization, regular-expression construction, and grouped unit tests without covering regex internals.
Examples
Demonstrates book-title queries such as “Habit,” “7 Habit,” “habits of,” and “abit.”
What it assumes
Assumes basic string searching and unit testing, while introducing the regular-expression word-boundary metacharacter from zero.
What you can do after
Apply it via JavaScript regular expressions to implement and unit-test case-insensitive search prefixes.
How it connects
Connects regular expressions, word boundaries, case-insensitive matching, search, and unit testing.

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming: Reduce software complexity. The section links point to the parts of the book it draws on.