Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Adds "\s* betweek each character of the string
- * Used to generate regexp with matches with or without spaces
- *
- * @example
- * // returns "h\s*e\s*l\s*l\s*o"
- * addSpaces("hello");
- * @returns {String} Returns the string processed.
- */
- function addSpaces (word) {
- return [...word].map((e, i) => i < word.length - 1 ? [e, '\\s*'] : [e]).reduce((a, b) => a.concat(b)).join('')
- }
Add Comment
Please, Sign In to add comment