How to remove all the text which contains 32 characters?

There is a file with a large amount of data must be done so that all of the text in which 32 characters have been deleted, for example if the file is text, containing 32 characters, then it needs to be removed, that is, the text 12345678901234567890123456789012 after running the script needs to be removed (As the text contains 32 characters), the rest of the text containing more or less number of characters needs to be saved
12345678901234567890123456789012
March 29th 20 at 23:44
1 answer
March 29th 20 at 23:46
Solution
1. Create a bufio.Reader, this caused bufio.NewReader(...), passing in an open file. https://golang.org/pkg/bufio
2. Call ReadString('\n') have created the reader, read the file line by line.
3. Each row beat the words with strings.Split(....," ")
4. Get array of words, run through it cycle and watch the length of the words.
5. Written to the file we need only those words that are shorter than 32 characters.

Important if you have a file contains only ASCII characters, it will be for sale, don't just look the number of bytes, and use the function https://golang.org/pkg/unicode/utf8/#RuneCountInString
Thank you - gabriella_Goyet commented on March 29th 20 at 23:49

Find more questions by tags Go