[R] Regular Expressions

John Bullock john.bullock at stanford.edu
Tue Jul 13 04:47:15 CEST 2004


If you use the RPerl interface
(http://www.omegahat.org/RSPerl/), you can do this simply
for any number of expressions by letting Perl do the
matching.  If "strings" is the array of strings that you
want to test, all you need is

    for (@strings) {
        if (/thomas/ && /perl/ && /prog/) {do something}
        }

But I don't know a simple way to do it in R.

--John

----- Original Message ----- 
From: "Sangick Jeon" <sijeon at ucdavis.edu>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, July 12, 2004 4:59 PM
Subject: [R] Regular Expressions


>
>
> Hi,
>
> Is there a way to use regular expressions to capture
two or more words in a
> sentence?  For example, I wish to to find all the lines
that have the words "thomas",
> "perl", and "program", such as "thomas uses a program
called perl", or "perl is a
> program that thomas uses", etc.
>
> I'm sure this is a very easy task, I would greatly
appreciate any help.  Thanks!
>
> Sangick
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html




More information about the R-help mailing list