4 ms·
I'm sorry I'm not familiar with the mathematics behind regular expressions. Can you give an example of what your approach would look like?
by 63 3y ago
I'm sorry I'm not familiar with the mathematics behind regular expressions. Can you give an example of what your approach would look like?
- dumbo-octopus 3y agofirst = 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!