The task here is to remove all leading and trailing spaces and tabs from the string. We will use some methods to reach the goal.
Method 1: Here, we will be using trim() method. We can strip a string using trim() method and can remove unnecessary trailing and leading spaces and tabs from the string.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.