A lightweight C++ fuzzy string matching library that provides fast and flexible fuzzy search functionality.
- Fuzzy string matching with scoring system
- Case-sensitive and case-insensitive matching support
- Special scoring for:
- Consecutive character matches
- First letter matches
- Camel case boundaries
- Extension starts
- Directory separators
- Word separators (space, underscore)
- Position tracking of matched characters
- Unicode support through wide strings
Just include the FuzzyMatcher.h and FuzzyMatcher.cpp files in your project.
#include "FuzzyMatcher.h"
// Create a matcher with a search pattern
FuzzyMatcher matcher(L"ptr");
// Score a target string
std::vector<size_t> positions;
int score = matcher.ScoreMatch(L"MyPointer", &positions);
// positions will contain the indices of matched characters
// score will indicate how well the string matches the pattern
The matching algorithm takes into account the following matching patterns:
- Basic character matches
- Case-sensitive matches
- First letter matches
- Consecutive character matches
- File extension boundaries (after '.')
- Directory separator matches (after '')
- Word separator matches (after space or underscore)
- Camel case word boundaries
A higher score indicates a better match quality.
- C++17 or later
- Compiler with wide string support
To run the tests, follow these steps:
- Create a build directory:
mkdir build
cd build
- Run CMake to build the project:
cmake ..
cmake --build .
- Run the tests:
ctest
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.