Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fancy(input = []) {
- let num = Number(input.shift());
- let pattern = /^@#+(?=[A-Z])([A-Za-z0-9]{6,})(?<=[A-Z])@#+$/m;
- for (let i = 1; i <= num; i++) {
- let data = input.shift();
- let match = pattern.exec(data);
- if (match !== null) {
- let matches = match[1];
- let digits = matches.match(/\d+/g);
- if (digits !== null) {
- console.log(`Product group: ${digits.join('')}`);
- continue;
- }
- console.log(`Product group: 00`);
- continue;
- }
- console.log(`Invalid barcode`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement