Remove all text before colon

后端 未结 9 1178
天命终不由人
天命终不由人 2020-11-27 12:45

I have a file containing a certain number of lines. Each line looks like this:

TF_list_to_test10004/Nus_k0.345_t0.1_         


        
9条回答
  •  失恋的感觉
    2020-11-27 13:31

    Some very simple move that I missed from the best response @Sacha Epskamp was to use the sub function, in this case to take everything before the ":"(instead of removing it), so it was very simple:

    foo <- "TF_list_to_test10004/Nus_k0.345_t0.1_e0.1.adj:PKMYT1"
    
    # 1st, as she did to remove all before and up to ":":
    gsub(".*:","",foo)
    
    # 2nd, to keep everything before and up to ":": 
    gsub(":.*","",foo)
    

    Basically, the same thing, just change the ":" position inside the sub argument. Hope it will help.

提交回复
热议问题