I know the program is written in ruby, but have you looked at hyperscan? Its a really fast regex parser if you need that kind of functionality. https://www.hyperscan.io/