Here are two ways of doing it in R:
foo <- "TF_list_to_test10004/Nus_k0.345_t0.1_e0.1.adj:PKMYT1"# Remove all before and up to ":":gsub(".*:","",foo)# Extract everything behind ":":regmatches(foo,gregexpr("(?<=:).*",foo,perl=TRUE))
A simple regular expression used with gsub():
gsub()
x <- "TF_list_to_test10004/Nus_k0.345_t0.1_e0.1.adj:PKMYT1"gsub(".*:", "", x)"PKMYT1"
See ?regex or ?gsub for more help.
?regex
?gsub
There are certainly more than 2 ways in R. Here's another.
unlist(lapply(strsplit(foo, ':', fixed = TRUE), '[', 2))
If the string has a constant length I imagine substr would be faster than this or regex methods.
substr