Skip to contents

Tests whether each element is a dotted version string, optionally v-prefixed and with a pre-release/build suffix: "1.4.0", "v2", "2.10.3", "v1.0", "3.2.1-rc1". A bare integer is not a version (that is a count/id); at least one dotted component or a v prefix is required.

Usage

is_version(x)

Arguments

x

A character vector of candidate values.

Value

A logical vector; TRUE for a version string, FALSE otherwise, NA where x is NA.

Examples

is_version(c("1.4.0", "v2", "2019", "banana", NA))
#> [1]  TRUE  TRUE FALSE FALSE    NA
#> TRUE TRUE FALSE FALSE NA