RE: how to find spaces with a regex?

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

 



grep " *" filename will also work, as does "\s*". "\s\{2,3\}" did not work for me, but " \{2,3\}" does. Actually, to get the desired results, I ended up using a regex of "\b \{2,3\}\b", because {2,3} matched three spaces, but really didn't care if the character following it was also a space.

grep "\b[:space:]*\b" filename works, but not "\b[:space:]\{2,3\}\b".

The command "perl -n -e "print if m/\b\s{2,3}\b/" filename works as does "perl -n -e "print if m/\b {2,3}\b/" filename .

So my question becomes: In grep, why won't the braced notation work with the symbolics for spaces when * and + do?

----
Robert P. Nix                            internet: nix.robert@xxxxxxxx
Mayo Clinic                                  phone: 507-284-0844
RO-CE-8-857                                page: 507-270-1182
200 First St. SW 
Rochester, MN 55905      
----   "Codito, Ergo Sum" 
"In theory, theory and practice are the same,
 but in practice, theory and practice are different."



> -----Original Message-----
> From:	fedora-list-admin@xxxxxxxxxx [SMTP:fedora-list-admin@xxxxxxxxxx] On Behalf Of Vincent
> Sent:	Thursday, February 19, 2004 10:23 AM
> To:	fedora-list@xxxxxxxxxx
> Subject:	Re: how to find spaces with a regex?
> 
> On Thu, 19 Feb 2004 11:11:29 -0400
> Trevor Smith <trevor@xxxxxxxxxxxxxx> wrote:
> 
> > On February 18, 2004 11:28 pm, Trevor Smith wrote:
> > 
> > > can NOT figure out how to use a regex to search for multiple spaces -- for
> > 
> > Sorry, I figured it out.
> > 
> >    grep ' {1,}' filename
> > 
> > does not work
> > 
> >    grep ' \{1,\}' filename
> > 
> > does work. I was forgetting to escape the { and } characters.
> > 
> > -- 
> >  Trevor Smith    |    trevor@xxxxxxxxxxxxxx 
> > 
> > 
> > -- 
> > fedora-list mailing list
> > fedora-list@xxxxxxxxxx
> > To unsubscribe: http://www.redhat.com/mailman/listinfo/fedora-list
> 
> for future reference \s means space \t means tab \S means NON-whitespace




[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux