[R] grep searching for sequence of 3 consecutive upper case letters

David Barron mothsailor at googlemail.com
Mon Nov 6 23:37:20 CET 2006


Try

str[grep('[[:upper:]]{3}',str)]


On 06/11/06, Lapointe, Pierre <Pierre.Lapointe at nbf.ca> wrote:
> Hello,
>
> I need to identify all elements which have a sequence of 3 consecutive upper
> case letters, anywhere in the string.
>
> I tested my grep expression on this site: http://regexlib.com/RETester.aspx
>
> But when I try it in R, it does not filter anything.
>
> str <-c("AGH", "this WOUld be good", "Not Good at All")
> str[grep('[A-Z]{3}',str)] #looking for a sequence of 3 consecutive upper
> case letters
>
> [1] "AGH"                "this WOUld be good" "Not Good at All"
>
> Any idea?
>
> Pierre
>
> **************************************************
> AVIS DE NON-RESPONSABILITE: Ce document transmis par courrie...{{dropped}}
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
=================================
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP



More information about the R-help mailing list