[R] toupper does not work in sub + regex
    Tan, Richard 
    RTan at panagora.com
       
    Mon Apr 13 18:10:33 CEST 2009
    
    
  
Thanks, Martin.  I did not realize that.  I never used perl compatible
regex before but seems now I should!
Richard
-----Original Message-----
From: Martin Morgan [mailto:mtmorgan at fhcrc.org] 
Sent: Monday, April 13, 2009 12:08 PM
To: Tan, Richard
Subject: Re: [R] toupper does not work in sub + regex
"Tan, Richard" <RTan at panagora.com> writes:
> Hi, I don't know what I am doing wrong to the toupper does not seem 
> working in sub + regex.  The following returns 's' not the upper class
> 'S' as I expect:
>  
> sub("q_([a-z])[a-zA-Z]*",toupper('\\1'),"q_sviRaw")
you're expecting toupper to be evaluated after substitution, but it is
evaluated before: toupper('\\1') ==> '\\1'. try
  sub("q_([a-z])[a-zA-Z]*",'\\U\\1',"q_sviRaw", perl=TRUE)
  
> Can someone tell me where I did wrong?
>  
> Thanks,
> Richard
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org 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.
--
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center 1100
Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793
    
    
More information about the R-help
mailing list