Remove Whitespace from Start and End 正则表达式:删除开头和结尾的空白


#1

Tell us what’s happening:

这一串代码中,| 这个 字符的作用是什么?为什么用\w+代替不可以?

Your code so far


let hello = "   Hello, World!  ";
let wsRegex = /^\s+|\s+$/g;; // 修改这一行
let result = hello.replace(wsRegex,''); // 修改这一行

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.one/javascript-algorithms-and-data-structures/regular-expressions/remove-whitespace-from-start-and-end