regex is not working until gcc 4.9.0, then this is an alternative