port re2 from https://code.google.com/p/re2/