[R] regex find anything which is not a number
Adrian Dușa
dusa.adrian at unibuc.ro
Thu Mar 12 23:05:20 CET 2015
On Thu, Mar 12, 2015 at 9:52 PM, John McKown
<john.archie.mckown at gmail.com> wrote:
> [...]
> One problem is that Adrian wanted, for some reason, to exclude numbers
> such as "2." but accept "2.0" . That is, no unnecessary trailing
> decimal point. as.numeric() will not fail on "2." since that is a
> number. The example grep() specifically excludes this by requiring at
> least one digit after any decimal point.
Indeed, but that was completely unintentional since I knew ".2" should
be a number and I somehow thought "2." was not supposed to be a
number.
I learned a lot about regular expressions (thanks again John), and
both solutions work (thanks very much Steve as well).
Best,
Adrian
--
Adrian Dusa
University of Bucharest
Romanian Social Data Archive
Soseaua Panduri nr.90
050663 Bucharest sector 5
Romania
More information about the R-help
mailing list