[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Question relating regexp



Robert Land wrote:
> An example from the phone list:
> ....
> 1248   Kate 634
> ....
> 1548  Kerry 534
> ....
> 
> To match a line that starts with a 1, 
> has some digits, at least one space 
> and a name that starts with a K we can write:
> 
> grep '^1[0-9]\{1,\} \{1,\}K' phonelist.txt
> or use * and repeat [0-9] and space:
> grep '^1[0-9][0-9]*  *K' phonelist.txt
> "
> 
> 
> Why, in the first example, has the author
> prefaced the char 'K' with the one or more
> times multiplier? He only wants to find a 
> name beginning with 'K'(!)

You're misreading it. The quantity applies to the _preceding_ character,
not the _subsequent_ character.

Craig

Attachment: pgpu9SvMBb4Ta.pgp
Description: PGP signature


Reply to: