Replace regex with substring to make it more efficient.