What would look regex for selecting every white space? I've tried to do few combinations, including excluding nums, digits etc but to no avail.
You can easily trim unnecessary whitespace from the start and the end of a string or the lines in a text file by doing a regex search-and-replace. Search for ^[ \t]+ and replace with nothing to delete leading whitespace (spaces and tabs). Search for [ \t]+$ to trim trailing whitespace.
The RegExp \s Metacharacter in JavaScript is used to find the whitespace characters. The whitespace character can be a space/tab/new line/vertical character. It is same as [ \t\n\r].
You can stick optional whitespace characters \s* in between every other character in your regex. Although granted, it will get a bit lengthy.
What about a simple
\s+
together with a match_all method or option, depending on your language?
See it here online on Regexr, the good place to test regular expressions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With