#!/usr/bin/env node; const Utils = require('./Utils'); const main = async () => { const s = "Four score and seven years ago..."; console.log(["Match 1: ", Utils.defined(s.match(/s.*e/))].join('')); console.log(["Match 2: ", Utils.defined(s.match(/\bs.*e\b/))].join('')); console.log(["Match 3: ", Utils.defined(s.match(/s...e/))].join('')); console.log(["Match 4: ", Utils.defined(s.match(/b.d/))].join('')); let subgroups = Utils.match(/(\w+)\s*(\w+)/, s); console.log(["Find First (with subgroups): ", Utils.listToString(subgroups)].join('')); subgroups = Utils.match(/bad match/, s); console.log(["Find First (bad match): ", Utils.listToString(subgroups)].join('')); let matches = Utils.match(/\w+/g, s); console.log(["Find All: (matches only)", Utils.listToString(matches)].join('')); matches = Utils.match(/bad match/g, s); console.log(["Find All (bad match): ", Utils.listToString(matches)].join('')); } main().catch( e => { console.error(e) } );