You need the substring function.
Or use gsub to work in a single snapshot:
> gsub('^[^[:digit:]]*[[:digit:]]', '', 'abc1def') [1] "def"
You can include this first digit, which can be done using capture:
> gsub('^[^[:digit:]]*([[:digit:]])', '\\1', 'abc1def') [1] "1def"
Or, as the flopel and Alan point out, just replace βall leading numbersβ with a space. See answer flodel.
Matthew lundberg
source share