Locate a pattern in the text, exactly or fuzzily.
()
| 104 | |
| 105 | // Locate a pattern in the text, exactly or fuzzily. |
| 106 | func ExampleDiffMatchPatch_MatchMain() { |
| 107 | dmp := diffmatchpatch.New() |
| 108 | |
| 109 | text := "The quick brown fox jumps over the lazy dog." |
| 110 | |
| 111 | fmt.Println(dmp.MatchMain(text, "quick brown", 0)) |
| 112 | fmt.Println(dmp.MatchMain(text, "quick grown", 0)) // typo, still found |
| 113 | |
| 114 | // Output: |
| 115 | // 4 |
| 116 | // 4 |
| 117 | } |
| 118 | |
| 119 | // Cleanup shifts edits to word boundaries: the raw diff on the left |
| 120 | // splits words, the cleaned up diff on the right edits whole words. |