Quantcast

How to specify multiple regular expressions for pattern argument

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

How to specify multiple regular expressions for pattern argument

Jun Shen-3
Dear list,

I want to show all the objects starting with "d" and ending with a digit.
How do I specify these conditions in the pattern argument

I can do one condition but not two

ls(pattern='^d')
ls(pattern='[[:digit:]]$')

are working.

But,

ls(pattern='^d'&'[[:digit:]]$') is not working.

Appreciate any comment.

Jun Shen

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to specify multiple regular expressions for pattern argument

trinker


I'm curious about the 'real' answer myself but this would work:



ls(pattern='^d')[ls(pattern='^d') %in% ls(pattern='[[:digit:]]$')]


Cheers,Tyler Rinker

----------------------------------------

> Date: Fri, 11 May 2012 13:18:59 -0500
> From: [hidden email]
> To: [hidden email]
> Subject: [R] How to specify multiple regular expressions for pattern argument
>
> Dear list,
>
> I want to show all the objects starting with "d" and ending with a digit.
> How do I specify these conditions in the pattern argument
>
> I can do one condition but not two
>
> ls(pattern='^d')
> ls(pattern='[[:digit:]]$')
>
> are working.
>
> But,
>
> ls(pattern='^d'&'[[:digit:]]$') is not working.
>
> Appreciate any comment.
>
> Jun Shen
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
     
______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to specify multiple regular expressions for pattern argument

Jeff Newmiller
In reply to this post by Jun Shen-3
ls(pattern='^d.*[[:digit:]]$')
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<[hidden email]>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.

Jun Shen <[hidden email]> wrote:

>Dear list,
>
>I want to show all the objects starting with "d" and ending with a
>digit.
>How do I specify these conditions in the pattern argument
>
>I can do one condition but not two
>
>ls(pattern='^d')
>ls(pattern='[[:digit:]]$')
>
>are working.
>
>But,
>
>ls(pattern='^d'&'[[:digit:]]$') is not working.
>
>Appreciate any comment.
>
>Jun Shen
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: How to specify multiple regular expressions for pattern argument

Berend Hasselman
In reply to this post by Jun Shen-3

On 11-05-2012, at 20:18, Jun Shen wrote:

> Dear list,
>
> I want to show all the objects starting with "d" and ending with a digit.
> How do I specify these conditions in the pattern argument
>
> I can do one condition but not two
>
> ls(pattern='^d')
> ls(pattern='[[:digit:]]$')
>
> are working.
>
> But,
>
> ls(pattern='^d'&'[[:digit:]]$') is not working.

'^d.*[[:digit:]]$'

starting with a 'd', followed by zero or more of anything and ending with a digit.

Berend

______________________________________________
[hidden email] 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.
Loading...