Tell us what’s happening:
So I don’t know if I correctly understand what I’m to do. I tried capturing each word and using just that for the replace, and now I tired this and my thoughts are that I’m just capturing the string “Hello, World!” without the spaces and when I replace it with that group it doesn’t use the spaces. Should I be trying to capture only the white space? I tried to have wsRegex =^(\s)$ . sp the replace could just be ‘’ getting rid of the white space at the beginning and end. Sorry for the long post I’m just trying to get more information since I didn’t really find the hints to helpful and I don’t want to be spoiled on the answer. Advice is appreciated.
Your code so far
let hello = " Hello, World! ";
let wsRegex = /^\s(\w+\W\s\w+\W)\s$/; // Change this line
let result = hello.replace(wsRegex, '$1'); // Change this line
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/109.0
Challenge: Regular Expressions - Remove Whitespace from Start and End
Link to the challenge: