x <- c("gender_gender-1", "county_county-2", "country_country-1997", "country_country-1993", "county-county-county-2")
gsub("^(.*?)(?:[,_\\s-]\\1)+", "\\1", x, perl=TRUE)