valid_postcode_1 <- function(x) {
# remove whitespace
x <- gsub("\\s", "", x)
# convert to upper case
x <- toupper(x)
# regex (this allows for cas)
pattern <- "^([A-Za-z][A-Ha-hJ-Yj-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})$"
# return indices of postcodes that match pattern
grep(pattern, x, perl = TRUE)
}
valid_postcode_1 <- function(x) {
# remove whitespace
x <- gsub("\\s", "", x)
# convert to upper case
x <- toupper(x)
# regex (this allows for cas)
pattern <- ^(([A-Z][0-9]{1,2})|(([A-Z][A-HJ-Y][0-9]{1,2})|(([A-Z][0-9][A-Z])|([A-Z][A-HJ-Y][0-9]?[A-Z])))) [0-9][A-Z]{2}$
# return indices of postcodes that match pattern
grep(pattern, x, perl = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.