String Methods To Remove Whitespace At The Beginning And End

[Solved] String Methods To Remove Whitespace At The Beginning And End | Swift - Code Explorer | yomemimo.com
Question : string methods to remove whitespace at the beginning and end of strings

Answered by : smiling-skunk-96ktnmjgs6m9

let hello = " Hello, World! ";
let wsRegex = /^\s+|\s+$/g; // Change this line
let result = hello.replace(wsRegex, ""); // Change this line

Source : https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-remove-whitespace-from-start-and-end/301362 | Last Update : Sun, 24 Apr 22

Answers related to string methods to remove whitespace at the beginning and end of strings

Code Explorer Popular Question For Swift