
Robert S. answered 11/24/19
R Developer and Analyst
There are a couple ways to do what you'd like:
1. With `substr()``, it can be `substr(string, 4, nchar(string))`; with `substring()`, it can be shortened to `substring(string, 4)`.
2. If you want to pattern-match more explicitly, I would suggest `gsub()` (I also recommend reading the documentation for this function: https://stat.ethz.ch/R-manual/R-devel/library/base/html/grep.html). See below for how to use this function for your case.
```
gsub('.*:', '', string)
# . = any character
# * = any number of times
# Result:
# [1] "E001" "E002" "E003"
```
What the above code block does is that it looks for any character (denoted by the period) that occurs any number of times (denoted by the asterisk) followed by a colon. Then it substitutes it with a blank character (''). Result should be the vector `c(E001, E002, E003)`.
Hope this helps!