Before testing this code, please make sure you have:
Clone repo:
git clone https://github.com/kanow-algorithms/naive-string-matcher.git
To run tests run this command in the root of this project:
cargo test
naive_string_matcher takes two parameters:
- text → is a reference to vector of all characters in which you want to find the word
- pattern → is a reference to vector of all search word characters
Input:
let text = vec!['H', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'];
let pattern = vec!['w', 'o', 'r', 'l', 'd'];
naive_string_matcher(&text, &pattern);
Output:
[6]
On this graphic you can see how naive-string-matcher algorithm works: