I’m in the JavaScript Lesson “Specify Upper and Lower Number of Matches” and I am kindof confused by the correct answer:
let ohStr = "Ohhh no";
let ohRegex = /oh{3,6}\sno/i; // Change this line
let result = ohRegex.test(ohStr);
This is my understanding & confusion:
-The first segment “oh” checks the string starts with “oh” characters. Why doesn’t it work if you use “h” instead?
-The second segment “{3,6}” searches for “h” character 3 to 6 times. Or is it checking for the “oh” 3 to 6 times? Or checking for “h” 3 to 6 times following an “o”?
-The third segment searches for whitespace.
-The fourth segment searches for “no” characters. Why is this part necessary?
-The fifth segment “/i” ignores case.