Skip to content
Prev 295776 / 398502 Next

How to remove square brackets, etc. from address strings?

Hello,

Though I've not been following this thread, it seems like a regular 
expressions problem.
In the code below, I've created a 'testdata' variable based on your post.

# create a vector with two elements.
x <- "[Engel, Kathrin M. Y.; Schroeck, ... etc ...
y <- gsub("Germany", "Portugal", x)
testdata <- c(x, y)

# 's' is a list of character vectors, each element's final word is a 
country
s <- strsplit(testdata, ";[[:space:]]+\\[")
lapply(s, function(x) sapply(strsplit(x, "[[:blank:]]"), tail, 1))


If this isn't it, sorry for the intrusion.

Rui Barradas

Em 27-05-2012 17:29, Sabina Arndt escreveu: