I\'m looking for a regular expression to catch all digits in the first 7 characters in a string.
This string has 12 characters:
A12B345CD678
The regex solution is cool, but I'd use something easier to read for maintainability. E.g.
library(stringr) str_sub(s, 1, 7) = gsub('[A-Z]', '', str_sub(s, 1, 7))