Your question is Complex String Manipulation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Nextdoor search supports simple query expressions over post text. Implement a function that determines whether a post matches a query containing ordinary terms, quoted phrases, and exclusions.
A positive term or phrase must appear in the post. All positive clauses must match. A clause prefixed with - must not appear. Matching is case-insensitive, and punctuation separates words. Terms match whole words, while quoted phrases must match consecutive whole words.
Implement matches_post(post, query), where both arguments are strings. Return True if the post satisfies every clause in the query, otherwise return False.
The query is valid and follows these rules:
"street parking".-, such as -sale or -"garage sale".def matches_post(post, query):