删除冒号前的所有文本 [英] Remove all text before colon
本文介绍了删除冒号前的所有文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含一定数量行的文件.每一行看起来像这样:
I have a file containing a certain number of lines. Each line looks like this:
TF_list_to_test10004/Nus_k0.345_t0.1_e0.1.adj:PKMYT1
我想删除:"之前的所有字符,以便仅保留作为基因名称的 PKMYT1.由于我不是正则表达式脚本方面的专家,谁能帮助我使用 Unix(sed 或 awk)或 R 来完成此操作?
I would like to remove all before ":" character in order to retain only PKMYT1 that is a gene name. Since I'm not an expert in regex scripting can anyone help me to do this using Unix (sed or awk) or in R?
推荐答案
在 R 中有两种方法:
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))
这篇关于删除冒号前的所有文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文