Q:

Removing middle initial from end of string in R

Need help removing the middle initial from the end of a string, but am not sure how to write the regex pattern out to do this in R.
Vector like:
x <- c("SMITH, BOB A.", "BISHOP, MATTHEW", "CLARK, CORY B")

Desired output:
[1] "SMITH, BOB"    "BISHOP, MATTHEW"    "CLARK, CORY"

Tried the following, but it may be way off 
test <- sub('^(\\w+)(\\W)(\\h)(\\w+)(\\h).*\\b$', '\\1 \\2',vec2)

Tried to replicate the answer from this other post, but don't think it's quite right.

A:

You could use
x <- c("SMITH, BOB A.", "BISHOP, MATTHEW", "CLARK, CORY B")
gsub("(.*)\\s+[A-Z]\\.?$", "\\1", x)

Which yields
[1] "SMITH, BOB"      "BISHOP, MATTHEW" "CLARK, CORY"    

