Path: utzoo!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!asuvax!ncar!virga.rap.ucar.edu!tres From: tres@virga.rap.ucar.edu (Tres Hofmeister) Newsgroups: comp.unix.shell Subject: Puzzled by A Regexp... Keywords: What's the extent of the match? Message-ID: <10469@ncar.ucar.edu> Date: 4 Mar 91 21:15:51 GMT Sender: news@ncar.ucar.edu Reply-To: tres@virga.rap.ucar.edu (Tres Hofmeister) Distribution: usa Organization: Research Applications Program/NCAR, Boulder, CO Lines: 31 I've run across a regular expression that I don't quite understand. Not that this hasn't happened before, but this seems like it should be fairly straightforward... I'm trying to match entries in /etc/group which have one or more members. The following works just fine, matching each of the colon delimited fields individually followed by one or more characters: grep '^.*:.*:.*:..*' /etc/group What I don't understand is why the following doesn't work the same way: grep '^.*:..*' /etc/group It grabs entries with one or more members, true, but also grabs entries with no members, e.g. "news:*:6:". I figured that this regexp would match the longest possible string at the beginning of a line, terminated by a colon, which in the group file should include the first two colons, followed by at least one character. It seems to be doing something else, given that it will also match a line with no members. Any ideas? Tres Hofmeister tres@ncar.ucar.edu -- Tres Hofmeister tres@ncar.ucar.edu