I need to identify patterns in a text file for further analysis. So the input files may contain semi-structured text as follows;
file1
905:john: abc123: [email protected]: US
920:eric: ericaA: [email protected]: US
1000: rio: ri0ri0: [email protected]: IN
file2
nathen <tab> [email protected] <tab> 764323545 <tab> UK
thomas <tab> [email protected] <tab> 563363421 <tab> UK
ian <tab> [email protected] <tab> 3453245472 <tab> SP
number of words in a line may vary for each document. delimiter also vary but unique for each document. what I want is to count number of words per each line in each document.
output would be:
for file1
5
5
5
5
for file2
4
4
4
4
I want generalize this for any file with any delimiter. It could be - | : \space+ \tab+
.
Some files are as follows:
| [email protected] | er34532 |
| [email protected] | 764474 |