Last active
February 16, 2017 01:08
-
-
Save mokargas/2bebfc6960d8e9d04ab72b6592dd42a4 to your computer and use it in GitHub Desktop.
Wrap text with spans
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Wraps a span tag around each character/letter | |
* | |
* @param {string} str The string to transform | |
* @returns {string} Input as split by chars/letters | |
*/ | |
wrapChars(str) { | |
return str.replace(/./g, "<span>$&</span>").replace(/\s/g, "<span> </span>"); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment