It splits the regex expression as close to the google limit as possible and in the last run it takes the rest. So it is not equally distributed.
Your last approach splitted the file into equal parts, but this didn't work correctly. I assume because the variable eachFile wasn't updated in the loop according to the searched pipe in each part of the string.
Maybe you would like to correct your solution or check if you also like my approach.
111 with multiple files.
It splits the regex expression as close to the google limit as possible and in the last run it takes the rest. So it is not equally distributed.
Your last approach splitted the file into equal parts, but this didn't work correctly. I assume because the variable eachFile wasn't updated in the loop according to the searched pipe in each part of the string.
Maybe you would like to correct your solution or check if you also like my approach.