[R] regex [:digit:] gives diffrent result

William Dunlap wdunlap at tibco.com
Mon Feb 6 19:51:23 CET 2017


Shouldn't your "[:digit:]" be "[[:digit:]]"?
Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Mon, Feb 6, 2017 at 10:36 AM, Tilmann Faul <Tilmann_Faul at t-online.de> wrote:
> Using R is a grate advantage, thanks for your work.
>
> Using regex under R 3.1.1, Debian 8.6 jessy works fine.
>
> str_detect("16-03-08", "[:digit:]{2}")
> [1] TRUE
> str_detect("16-03-08", "[0-9]{2}")
> [1] TRUE
>
> runing the same code under R 3.3.2 backport, Debian 8.6 jessy gives a
> different result. This is also a different computer.
>
> str_detect("16-03-08", "[:digit:]{2}")
> [1] FALSE
> str_detect("16-03-08", "[0-9]{2}")
> [1] TRUE
>
> Is this intended?
> My workaround is using [0-9] instead of [:digit:].
>
> Thanks
> Tilmann
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.



More information about the R-help mailing list