Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 1022 Bytes

README.md

File metadata and controls

53 lines (35 loc) · 1022 Bytes

naive-string-matcher

Requirements

Before testing this code, please make sure you have:

Installation

Clone repo:

git clone https://github.com/kanow-algorithms/naive-string-matcher.git

Testing

To run tests run this command in the root of this project:

cargo test

Description

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

Example

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]

How it works

On this graphic you can see how naive-string-matcher algorithm works:

NaiveStringMatcher