Hi,
Thsi regular expression works for me:
echo "hiiii" | gawk --posix '/i{2}/ {print "ji"}'
ji
As per the gawk guide notes below:
"However, because old programs may use `{' and `}' in regexp
constants, by default gawk does not match interval expressions in
regexps. If either --posix or --re-interval are specified (see
Options), then interval expressions are allowed in regexps.
For new programs that use `{' and `}' in regexp constants, it is good
practice to always escape them with a backslash. Then the regexp
constants are valid and work the way you want them to, using any
version of awk.14 "
I try backslah option as
echo "hiiii" | gawk '/i\{2\}/ {print "ji"}'
But this does not give expected output. Can someone please help me
with this.
Thanks,
Prateek
echo "hiiii" | gawk '/i\{2\}/ {print "ji"}'


|