String Pattern Matching Algorithm