Antecedents feed

Last night, an operator came to say that when importing Excel, a phone number kept reporting errors when verifying data: the phone number was not correct. At that time, they were puzzled, but because it was too late, they would deal with it the next day.

Found the problem

Early in the morning ran to the company, the first thing is to fix this bug, at first thought is the reason for the space, because the phone number is not done to the space processing, plus! Add it right now! ^(1)\d{10}$^(1)\d{10}$ So the first manual input of the number for verification, found that can pass, then immediately thought of the possible data problem, and then to the incoming parameters of the copy of the number, found that can also pass verification, so that identified, the pot must be the back end, dumped on the end. Back-end initially thought it was accidentally added Spaces, in the process of incoming to regular check fails, then add remove Spaces, but found no, and found that only the excel enter any number of a cell is an error, so I went and parameter values, then will quote also take in, and then remove quotes, calibration, fail! At this point, we realize that there is a problem with this data, so we do unicode encoding for 11111111111, and the result is

The & # 8237; & # 49; & # 49; & # 49; & # 49; & # 49; & # 49; & # 49; & # 49; & # 49; & # 49; & # 49;Copy the code

The problem was that the length of the transcoding was 12, and a strange thing was revealed: &#8237. After the problem occurs, we look up the data, and it turns out that on some operating systems or some versions of Excel, there are some invisible codes, which is why neither the front end nor the back end prints out, and there’s no exception, so we just need to process the string and remove the special characters, right

str=str.toString().replace(/[\u200b-\u200f\uFEFF\u202a-\u202e]/g."")
Copy the code

The last

This is the first time I know there will be such invisible characters. It seems that there is still a long way to go. At the same time, the import part of my front-end Excel processing plug-in pikaz-Excel – JS has also added the function of removing Spaces and special characters. Welcome everyone to raise issue and improve it together, thank you.