Adding spaces in search phrase between alphabetics and numbers
Changing search input for better fuzzy matching
Often times combination of alphabetic and word inputs may yield no result if the input phrase is typed in without spaces.
Issue example
A post content contains these words:
The user types in the following search phrase:
The search will yield therefore NO result - because the search phrase "hello12345" does not match the content string in any way (phrase or it's parts are not a substring of the content).
For us humans this would be an obvious match, but the code can only look for parts of the search input. Words are by default only separated by word separators - commas, spaces, tabs etc..
Solution
What is this, and where do I put this custom code?
The custom code above will look for alphanumerics and numbers (and vice versa) in sequence and add spaces between them. Therefore typing in:
..becomes:
This will match the original post content, therefore resolves the issue.
Combined solution with extra character removal
In this knowledge base is a solution to replace some special word boundary characters, in case needed, here is a combination of the two codes.
What is this, and where do I put this custom code?
Last updated