The use of | in Javascript Regex

Tell us what’s happening:
I do not understand why the sign | is used as part of the solution. Doesn’t | mean OR? Wouldn’t that result in only either the front portion or the end portion to be selected instead of both? Please help to clarify it for me. Thank you.

Furthermore, would my solution be considered passable?

Your code so far

let hello = "   Hello, World!  ";
let wsRegex = /\s+(\S+)\s(\S+)\s+/; // Change this line
let result = hello.replace(wsRegex,"\1\s\2"); // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36.

Challenge: Remove Whitespace from Start and End

Link to the challenge:

with regards to your question about the bar, it is better to think of it like this, whitespace will be matched at the beginning or the end like the tests asks for . That means the regex in the solution is designed to pick up white space at the beginnning (before the bar) AND at the end ( after the bar). So it would pick up beginning white space alone, end white space alone, or both