[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: some suggest about \.
From: |
Aharon Robbins |
Subject: |
Re: some suggest about \. |
Date: |
Mon, 8 Mar 2004 13:49:39 +0200 |
Greetings. Re this:
> Date: Mon, 8 Mar 2004 18:00:07 +0800 (CST)
> From: =?gb2312?q?=D5=DF=20=B2=E2=CA=D4?= <address@hidden>
> Subject: some suggest about \.
> To: address@hidden
>
> $awk --version
> GNU Awk 3.1.1
3.1.3 is current, just for your information.
> Copyright (C) 1989, 1991-2002 Free Software Foundation.
>
> $cat iplog.txt
> 192.168.2.123 user1
> 192.168.2.123 user4
> 192.168.2.73 user2
> 119/168.2.66 user6
>
> ###### note: the 4th line input error on purpose to
> test the awk-script.
> $cat iplog.txt | awk --re-interval '{
> if($1 ~
> "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")
If you enclose your regex constant in / characters, you
won't have a problem
if ($1 ~ /....../) ....
Since you used a string constant, awk processes it for
escapes before the regular expression matcher ever sees it.
Inside a string constant, \. becomes a plain period, and is
thus treated as a metacharacter. This is explained in
the gawk documentation.
Arnold
- Re: some suggest about \.,
Aharon Robbins <=