Added support for random length patterns.