December 2023
Intermediate to advanced
242 pages
5h 28m
English
| Recipe 62 | Removing Duplicate Whitespaces |
Suppose you discover that the guest posts on your blog site contain not just extra space characters, but also other whitespace characters, like tabs. So, this time, you want to replace all whitespace characters, including space, tab (\t), line feed (\n), carriage return (\r), vertical tab (\v), form feed (\f), and others.
For instance, consider the following string, where the space between “My” and “life” is made up of two tab characters. You can confirm the presence of a tab character by searching for \t in the string:
| | const str = " My life needs editing."; |
| | |
| | /My\t\t/.test(str); // → true |
You need a solution that allows ...
Read now
Unlock full access