UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

23 lines (19 loc) 749 B
'use strict'; /** * Matches exactly one letter (lowercase or uppercase). * @param {string} [type='g'] - The flag for the regular expression (default is 'g'). * @returns {RegExp} The regular expression to match exactly one letter. */ function oneLetter(type = 'g') { return new RegExp('^[a-zA-Z]+$', type); // Matches exactly one letter } /** * Matches one or more letters (lowercase or uppercase). * @param {string} [type='g'] - The flag for the regular expression (default is 'g'). * @returns {RegExp} The regular expression to match one or more letters. */ function multiLetters(type = 'g') { return new RegExp('[a-zA-Z]+', type); // Matches one or more letters } exports.multiLetters = multiLetters; exports.oneLetter = oneLetter;