Brute-Force String Matching
Requires a Wolfram Notebook System
Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.
Brute-force string matching compares a given pattern with all substrings of a given text. Those comparisons between substring and pattern proceed character by character unless a mismatch is found. Whenever a mismatch is found, the remaining character comparisons for that substring are dropped and the next substring can be selected immediately. The visualization of this sliding selection window shows the selected characters in blue. The characters which are currently compared are printed in magenta. Note that brute-force searching usually involves automatic shifts upon mismatch to avoid unnecessary comparisons.
Contributed by: Michael Schreiber (March 2011)
Open content licensed under CC BY-NC-SA
"Brute-Force String Matching"
Wolfram Demonstrations Project
Published: March 7 2011