Trimming Strings
Learn how to remove certain characters from a string.
Trimming is the process of removing whitespace characters before the first non-whitespace character and after the last non-whitespace character of the string.
We often remove these unwanted whitespace characters when processing templates or processing user input. For instance, assuming that _
denotes a space, instead of entering _Zsolt
in a form field, you would expect that Zsolt
is saved in the database.
The trim
string method performs trimming:
Get hands-on with 1400+ tech skills courses.