Skip to content
Back to formatted view

Raw Message

Message-ID: <CAF8bMcZ+vQZQ=t-Np3nS_rp+e313qCp+ZkWR+E5+xvQHgcjwZg@mail.gmail.com>
Date: 2017-02-06T18:51:23Z
From: William Dunlap
Subject: regex [:digit:] gives diffrent result
In-Reply-To: <f908b96c-e844-5211-24f4-0571d10b6cec@t-online.de>

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.