use substr instead of backtracking regex, thanks rcaputo