Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fancybarCode(input) {
- let numGroups = input.shift();
- let firstPattern = /(@#{1,})([A-Z][A-Za-z\d]{4,}[A-Z])(@#{1,})/g
- let secondPatern = /\d+/g
- // /(@[#]+)(?<name>[A-Za-z0-9]){6,}\1/g
- for (let el of input) {
- let matches = (el.match(firstPattern) )
- if (matches!==null) {
- let word = matches[0];
- let digitChars = [...word].filter(digit => /\d/.test(digit)).join("");
- let result = digitChars === "" ? '00' : digitChars;
- console.log(`Product group: ${result}`);
- } else {
- console.log("Invalid barcode")
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement