Regular Expressions - Remove Whitespace from Start and End

Tell us what’s happening:
I have been trying to solve this and I have gone through the related post but I am not getting the point. I have “console.log” my result and get the desired output in the console of the editor but yet the test fails and gives the feedback “result should be equal to the string “Hello, World!” .” And my console.log provide the trimmed version of the hello message in the console the result as expected.

Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Regular Expressions - Remove Whitespace from Start and End

Link to the challenge:

Try wrapping the result with some delimiter characters, to make sure no spaces are left:


Thank you for the reply I checked using delimiter character and there are spaces at the end.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.