[R] starting with a capital letter
(Ted Harding)
Ted.Harding at manchester.ac.uk
Sat Sep 15 13:55:03 CEST 2007
On 15-Sep-07 10:21:19, kevinchang wrote:
>
> Hi everyone,
>
> I am wondering if there is any built-in funcion that can
> determine whether words in a character vector start with
> a captial letter or not. Help, please. Thanks.
Something like:
C<-c("Abc", "aBc", "abC")
for(i in (1:length(C))){
if(length(grep("^[A-Z]",C[i]))>0){
print("Yes") else print("No")
}
}
[1] "Yes"
[1] "No"
[1] "No"
The "grep" expression "[A-Z]" looks for one of A,B,C,...,Z
and the "^" makes it look for it at the start of the string.
Hoping this helps,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 15-Sep-07 Time: 12:55:00
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list