I have something like this
我有类似的东西
st1 <- "psi-mi:pcgf1_human(display_long)|uniprotkb:RING finger protein 68(gene name synonym)|uniprotkb:Nervous system Polycomb-1(gene name synonym)|uniprotkb:PCGF1(gene name)|psi-mi:PCGF1(display_short)|uniprotkb:NSPC1(gene name synonym)|uniprotkb:RNF68(gene name synonym)"
My expected output
我的预期产量
"PCGF1"
I am looking to get characters appear before (gene name) which is PCGF1
我希望在(基因名称)PCGF1之前出现字符
1 个解决方案
#1
4
We can try using sub()
:
我们可以尝试使用sub():
name <- sub(".*:([^:]*?)\\(gene name\\).*", "\\1", st1)
Demo here:
Rextester
#1
4
We can try using sub()
:
我们可以尝试使用sub():
name <- sub(".*:([^:]*?)\\(gene name\\).*", "\\1", st1)
Demo here: