4 ms·
first = line.match( /(?:(0|zero)|(1|one) ... (9|nine))/) last = line.match(/.*(?:(0|zero)|(1|one) ... (9|nine))/) indexOfGroupMatched = ([_,
by dumbo-octopus 3y ago
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('')
- 63 3y agoOh I understand. That's a good idea. Honestly I only ever use regex for AOC so I never would've thought of using it like that. I'll keep it in mind. Thanks!