hi, i need help understanding the regex.
i completed the regex section practice but, definately peeked at the hint and solution after i could not understand it on my own.
I can understand the use of “|” and “&”. like
let wsRegex = /(^\s+)|(\s+$)/;
why isn’t the code working if i use “&” instead of “|”
i.e. last exercise in regex section
Why can’t we specify a regex like this
let reRegex = /^\s$/;
similarly
i can’t understand the capture groups
let repeatNum = "42 42 42";
let reRegex = /^(\d+)\s\1\s\1$/;
let result = reRegex.test(repeatNum);
why cant the regex be
let reRegex = /(\d+)\s\3/;
doesn’t this match numbers separated with space occurring 3 times
thanks