fixing regex to search for invalidly encoded character sequences