If the string should be of fixed length, then substr
from base R
can be used. But, we can get the position of the .
with regexpr
and use that in substr
substr(a, 1, regexpr("\\.", a)-1)
#[1] "NM_020506" "NM_020519" "NM_001030297" "NM_010281" "NM_011419" "NM_053155"