grepSubString function

Pattern matching.