Text this: Distribution theory of runs and patterns and its applications