x <- c("AnonEtAl2010", "AnotherEtAl2011", "OnemoreEtAl2012", "LastoneEtAl2013")
gsub("(?!^)([A-Z]|[[:digit:]]+)", " \\1", x, perl=T)
#which gives
> gsub("(?!^)([A-Z]|[[:digit:]]+)", " \\1", x, perl=T)
[1] "Anon Et Al 2010" "Another Et Al 2011" "Onemore Et Al 2012"
[4] "Lastone Et Al 2013"
> x <- c("AnonEtAl2010", "AnotherEtAl2011", "OnemoreEtAl2012", "LastoneEtAl2013", "Anon2013", "SomeoneAnother2013")
>
> gsub("(?!^)([A-Z]|[[:digit:]]+)", " \\1", x, perl=T)
[1] "Anon Et Al 2010" "Another Et Al 2011" "Onemore Et Al 2012"
[4] "Lastone Et Al 2013" "Anon 2013" "Someone Another 2013"
x <- c("AnonEtAl2010", "AnotherEtAl2011", "OnemoreEtAl2012", "LastoneEtAl2013", "Anon2013", "SomeoneAnother2013")
# (?!^) : Don't match the beginning of the string (this requires using perl=TRUE)
# ([[:upper:]]|[[:digit:]]+) : Match either an upper case letter or a group of numbers and create a 'group' out of it
# " \\1" : replace the match with a space followed by the 'group' (ie the match)
gsub("(?!^)([[:upper:]]|[[:digit:]]+)", " \\1", x, perl = TRUE)