SyntaxFix
Write A Post
Hire A Developer
Questions
Or simply:
as.numeric(gsub("\\D", "", years)) # [1] 20 1