Created
January 19, 2021 16:19
-
-
Save otaviocorrea/c7fb9d982eaa6994ad6038f1510f9b80 to your computer and use it in GitHub Desktop.
Function for print lines and spaces of texts with javascript, Svelte, React e etc.
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
const DoWhiteSpace = (text) => { | |
const spacesRegexp = /\x20/g, newLineRegexp = /\n/g; | |
return text.replace(spacesRegexp, ' ').replace(newLineRegexp, '<br>'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment