It's a Regular Language, in the mathematical sense. All you need is the greedy match anything sequence, I don't know why so many people jumped to non-Regular regex extensions.
first = line.match( /(?:(0|zero)|(1|one) ... (9|nine))/)
last = line.match(/.*(?:(0|zero)|(1|one) ... (9|nine))/)
indexOfGroupMatched =
([_, ...groups]) => groups.findIndex(x => x != undefined)
num = +[first, last].map(indexOfGroupMatched).join('')