Learn R Programming

assertive (version 0.2-1)

assert_all_are_uk_telephone_numbers: Is the string a valid UK telephone number?

Description

Checks that the input contains UK telephone numbers.

Usage

assert_all_are_uk_telephone_numbers(x)

assert_any_are_uk_telephone_numbers(x)

is_uk_telephone_number(x)

Arguments

x
Input to check.

Value

  • is_uk_telephone_number returns TRUE if the input string contains a valid UK telephone number. The {assert_*} function returns nothing but throws an error when the is_* function returns FALSE.

References

The regex is adapted from one on the now defunct aa-asterisk.org.uk site with some additional consultation from https://en.wikipedia.org/wiki/List_of_United_Kingdom_dialling_codes

Examples

Run this code
phone_nos <- c("+44 207 219 3475", "08457 90 90 90")
is_uk_telephone_number(phone_nos)
assert_all_are_uk_telephone_numbers(phone_nos)

Run the code above in your browser using DataLab