On Aug 2, 2011, at 8:07 PM, John Sorkin wrote:

windows 7
R 2.12.1

Is there any easy way to determine if a sting contains nothing but blanks? I need to check a series of strings of various length.

OneBlank <- " "
TwoBlanks <- "  "
ThreeBlanks <- "   "
NoBlanks <- "NoBlanks"

What I want would be a function such as ALLBLANKS that would return the following
ALLBLANKS(OneBlank) would be true (or 1)
ALLBLANKS(TwoBlanks) would be true (or 1)
ALLBLANKS(ThreeBlanks) would be true (or 1)
ALLBLANKS(NoBlanks) would be false (or 0)

> bvec <- c(OneBlank, TwoBlanks ,ThreeBlanks ,NoBlanks)
> grepl(" +", bvec)
[1]  TRUE  TRUE  TRUE FALSE

--
David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to