Tell us what’s happening:
I want to remove whitespace by the regex
/(^\s+)(.*)(\s+$)/,I thought $2 might be the part with whitespace removed from start and end
the start whitespace is removed but the end white space cannot be completely removed. there is one space left to $2 ,the second capture group. can somebody tell me why?
Your code so far
let hello = " Hello, World! "; let wsRegex = /(^\s+)(.*)(\s+$)/; // Change this line let result = hello.replace(wsRegex,'$2'); // Change this line console.log(result);
Your browser information:
User Agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.9 Safari/537.36.
Challenge: Remove Whitespace from Start and End