During this challenge, code that should pass all tests not work, but also certain tests pass that shouldn't, given the parameters of the challenge. For example, all tests save for 'Your regex should not match "Ohhhhhhh no"' pass with the following code:
let ohStr = "Ohhh no";
let ohRegex = /h{3,6}/; // Change this line
let result = ohRegex.test(ohStr);
...but I get the exact same results if I change the 6 in the quantity specifier brackets to a 5, 4, or 3.
Had the same problem and figured out putting a {3,6} just understands the 6 as an infinite, it's like a {n, infinity} so it will basically match whatever amount of h if it is more than 3.
You have to specify the end of what you want to match ;)
Here's the solution mate : https://repl.it/repls/VerticalLimpCamel
Ah, I see, I think you're correct. I should know better by now than the attempt these challenges without some outside docs on the subject matter and be sure that I understand the concept precisely
Yes, otherwise it just looks for 3 to 6 consecutive h characters in a string with 7 — so of course it finds it, there are actually two. Please close this report.
Thanks for sending!
On 21 Jun 2018 at 23:59,
wrote:
Closed #17446 https://github.com/freeCodeCamp/freeCodeCamp/issues/17446.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/freeCodeCamp/freeCodeCamp/issues/17446#event-1694748009,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ammamwkk8lrzo8UZOEoVcuVjdzrGxRTAks5t_BcqgaJpZM4UbPMe
.
The best solution to above problem:
Regular Expressions: Specify Upper and Lower Number of Matches
Recall that you use the plus sign + to look for one or more characters and the asterisk * to look for zero or more characters. These are convenient but sometimes you want to match a certain range of patterns.
You can specify the lower and upper number of patterns with quantity specifiers. Quantity specifiers are used with curly brackets ({ and }). You put two numbers between the curly brackets - for the lower and upper number of patterns.
For example, to match only the letter a appearing between 3 and 5 times in the string "ah", your regex would be /a{3,5}h/.
let A4 = "aaaah";
let A2 = "aah";
let multipleA = /a{3,5}h/;
multipleA.test(A4); // Returns true
multipleA.test(A2); // Returns false
Change the regex ohRegex to match only 3 to 6 letter h's in the word "Oh no".
solution:
let ohStr = "Ohhh no";
let ohRegex = /Oh{3,6}\sno/; // Change this line
let result = ohRegex.test(ohStr);
solution:
let ohStr = 'Ohhh no';
let ohRegex = /oh{3,6}\sno/i;
let result = ohReges.test(OhStr);
This should work....
'\s' will create a space
'i' will make it case insensitivity
Most helpful comment
Had the same problem and figured out putting a {3,6} just understands the 6 as an infinite, it's like a {n, infinity} so it will basically match whatever amount of h if it is more than 3.
You have to specify the end of what you want to match ;)
Here's the solution mate : https://repl.it/repls/VerticalLimpCamel