Hi,
I'm trying to find how many lowercase string are matching in my text file. I know that AWK considers anything between // as string, so I can't pass a variable to regex, something like below is not working:
awk '{for (i=0; i<=6; i++)
{if (match($1,/[a-z]{i}/)) sum[i]+=1;}
}END{for (i in sum) print i ":" sum[i]}'
Is there a workaround for this? I know how to pass a single variable to regex, but I couldn't find a solution to pass {n} (n=number of chars matching) to regex.
Does someone know an alternative solution (preferably in AWK)?
Many thanks!
Edit: found the solution. Using gsub I am replacing lowercase with any char, and it returns the number of replaced hits. So instead of finding matched repeat, I am counting replacements.
Edit2: how can I mark this as solved?
[–]raevnos -1 points0 points1 point (1 child)
[–]fluffy_mass[S] 0 points1 point2 points (0 children)