Redex: Remove Whitespace from Start and End Challange - Is this another valid solution?

Hey! I’ve just passed this challenge but I am not sure if it’s a valid solution what I’ve done. I would love to hear your opinion! Thank you in advance!

let hello = "   Hello, World!  ";
let wsRegex = /(\S+)\s(\S+)/; // Change this line
let result = hello.match(wsRegex)[0]; // Change this line

It’s not very flexible. It only works for a string that contains one word, followed by one space, followed by one word.

If hello were changed to " Hello ", you would get an error.

1 Like

That’s true!! Thank you very much for your help! =)