Regular Expressions - Reuse Patterns Using Capture Groups - Free Code Camp

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

I'm having a lot of trouble for regular expression because I feel the notation like .* + when combined with other notations is difficult to understand how things should be matched or repeated. Thank you for the insight when you should add ^ and + it clears up the cloud in my head a little

JazzFanss
Автор

Thanks man. Great to see a different perspective when learning!

treelee
Автор

Dude you explained this in ~4 minutes and made more sense than the free code camp explanation. I'm probably a better visual learner.

ianhnizdo
Автор

but on your code you added another 42 why instead of just dealing with the Regex only or is this also part of the challenge

vizlodunken
Автор

Thank you so much for explaining that, I totally get it ☺

zinebakerkkaou
Автор

Thank you so much for your help Mr. Ian
let repeatNum = "42 42 42";
let reRegex = /^(\d+)\s\1\s\1$/;
let result = reRegex.test(repeatNum);
console.log(result);

zken
Автор

I'm never going to get passed this problem.. nothing works

randomeverything
Автор

Why was their a second \s?
even though the first \s took care of it.
never mind, it only repeats the digit.
Either way, Thanks for explaining!

derlynhernandez
Автор

i want to split file for example 123VishalABC into 123, Vishal, ABC how to do that

vishalmishra
Автор

For ppl who failed with /^(\d+)\s\1\s\1$/ getting: Your regex should not match the string 42\t42\t42. This works: /^(\d+) \1 \1$/ 🤕🙄

rxzdhby
Автор

Hi! I do have a doubt and I hope you can help me:

let repeatStr = “row row row your boat”;

let repeatRegex = /(\w+) \1 \1/; // they refer to the substring twice

repeatStr.match(repeatRegex); // Returns [“row row row”, “row”]
//So over here shouldn’t that return [“row row row”, “row”, “row”]

So what is it that I´m missing this is the example that is RN on freecodecamp so could it be possible that is incorrect?

pancutirimicuaro