How to use the makeRe function from micromatch
Find comprehensive JavaScript micromatch.makeRe code examples handpicked from public code repositorys.
173 174 175 176 177 178 179 180 181 182
The following example shows how to create a glob that matches a numeric folder name between `01` and `25`, with leading zeros. ```js const fill = require('fill-range'); const regex = micromatch.makeRe('foo/{01..25}/bar', { expandRange(a, b) { return `(${fill(a, b, { toRegex: true })})`; } });
GitHub: grownjs/mortero
648 649 650 651 652 653 654 655 656 657
function rename(dest, filter) { const re = array(filter).reduce((memo, cur) => { if (typeof cur === 'function') memo.push({ fn: generate(dest, cur) }); if (typeof cur === 'string') cur = cur.split(':'); if (Array.isArray(cur)) { if (!(cur[0] instanceof RegExp)) cur[0] = micromatch.makeRe(cur[0], { dot: true }); memo.push({ fn: generate(dest, RegExp.prototype.test.bind(cur[0])), re: cur[1] }); } return memo; }, []);
GitHub: PandaJ0001/marihaks
153 154 155 156 157 158 159 160 161 162
} return parts; } exports.getPatternParts = getPatternParts; function makeRe(pattern, options) { return micromatch.makeRe(pattern, options); } exports.makeRe = makeRe; function convertPatternsToRe(patterns, options) { return patterns.map((pattern) => makeRe(pattern, options));
GitHub: cherniavskii/parcel
![cherniavskii profile picture](/cherniavskii.png?size=40)
17 18 19 20 21 22 23 24 25 26
let files = glob.sync(regularExpressionSafeName, { strict: true, nodir: true }); let re = micromatch.makeRe(regularExpressionSafeName, {capture: true}); let matches = {}; for (let file of files) { let match = file.match(re);
micromatch.isMatch is the most popular function in micromatch (132 examples)