my fork of dmp
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -21,7 +21,7 @@ A very **fast**, **accurate** and **wasm ready** port of [Diff Match Patch](http ```toml [dependencies] -diff-match-patch-rs = "0.2.1" +diff-match-patch-rs = "0.3.0" ``` ### `Effitient` mode @@ -145,6 +145,27 @@ fn main() -> Result<(), Error> { } ``` +### `Match` - fuzzy match of pattern in Text + +```rust +use diff_match_patch_rs::{DiffMatchPatch, Compat, Error, PatchInput}; + +// This is the source text +const TXT: &str = "I am the very model of a modern Major-General, I've information on vegetable, animal, and mineral, 🚀👏👀"; + +// The patter we are trying to fing +const PATTERN: &str = " that berry "; + +// Returns `location` of match if found, `None` if not found +fn main() -> Option<usize> { + let dmp = DiffMatchPatch::new(); + + // works with both `Efficient` and `Compat` modes + // `5` here is an approx location to find `nearby` matches + dmp.match_main::<Efficient>(TXT, PATTERN, 5) // this should return Some(4) +} +``` + #### Note The `Efficient` and `Compat` mode APIs are identical with the only chage being the `generic` parameter declared during the calls. |