Last active
January 10, 2025 10:25
-
-
Save ruzz311/073ae57c471a97b6cefa1a39db5d3a69 to your computer and use it in GitHub Desktop.
Regex example to remove spaces between tags (html, xml, etc.)
This file contains hidden or 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
// For regex testing https://regex101.com/r/dOjkeJ/2 | |
let myStr = `<something> | |
<xml-like> | |
<example><p>with lots of spaces</p></example> | |
and \n characters | |
<xml-like> | |
</something>`; | |
// spaces: | |
myStr.replace(new RegExp('\>[ ]+\<', 'g'), '><'); | |
// matches "\n" "\t" and " " (space) | |
myStr.replace(new RegExp('\>[\s]+\<', 'g'), '><'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well, almost 8 years later and it put me on track to make something work so, thank you