Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > Backslash with ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 2227 of 2234
Post > Topic >>

Backslash with interval expressions

by Prateek <prateek.a@[EMAIL PROTECTED] > May 1, 2008 at 09:37 AM

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"}'




 2 Posts in Topic:
Backslash with interval expressions
Prateek <prateek.a@[EM  2008-05-01 09:37:35 
Re: Backslash with interval expressions
pk <pk@[EMAIL PROTECTE  2008-05-01 18:40:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon May 12 2:51:52 CDT 2008.