just so people know, the number 15 at the end is not the groups added together, it is the index of where the match starts in the string. If you match the first character of the string, that index will be 0.
that was an amazing tutorial, i didn't even noticed that i'm watching the last one. in few hours i watched all your videos and i'm so thankful to learn from you. greetings from Syria you are the best.
I have a nice, simple application of applying functions for you: Suppose you have a text with timestamps in 12 h (am/pm) notation. Your task is to convert them to 24 h notation. You may assume that all timestamps have this format: 9:30 AM, 12:30 PM, 1:11 PM, etc. This should then become 9:30, 12:30, 13:11. I hope you like it! Converting AM to PM already is tricky.
This video just triggered a Eureka moment in my brain. I'm 35 and just started learning coding 4 months ago and I think I've just turned a corner. Thank u man. I'm not sure what u did, but it's like a fog has just lifted off of javascript for me.
Very usefull, now I finally can say that I've learned about RegEx whit your tutorials series. Thank you very much teacher Danniel, regards from Mexico :-). YOU ARE THE BEST!!!
The numbers 15, 109, and 166 seem to align with the first character of each of the "group zeros" searched. i.e. string[15] = 9 from "999-1324", string[109] = 1 from '111-8765', etc.
It's: "The offset of the matched substring within the whole string being examined. (For example, if the whole string was 'abcd', and the matched substring was 'bc', then this argument will be 1.)" Quoted from: developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/replace Daniel, why aren't you teaching how to read documentation? :) (I recommend pointing to MDN - Mozilla Developer Network, which is the best Javascript resource around. Even if it's not always super clear, it's a wiki and you can suggest changes). Poking around a blackbox is fun, but you might reach wrong conclusions.
*17:02* _15 was the starting index of the first match. It was a coincidence resulting "15" to the total sum of lengths of the arguments inside a function_
is it possible to say I want regex to capture a,b and c, but replace a with a certain section of a, replace be with a certian section of b, and replace c with a certain section of c... I was thinking that | would be used in the match part of the replace , but I havent found a decent example
Hello, why does this work in splitting out numbers and text words per every capital letter? userNameStructure: any; const userName = '91MickeyMouse'; this.userNameStructure = userName.replace(/([a-z0-9])([A-Z])/g, '$1 $2'); console.log('words', this.userNameStructure); RESULT: words 91 Mickey Mouse My goal is to capture Mickey as first name, Mouse as last name. I was thinking I could call a function in place of '$1 $2', but that seems to fall apart.
I used regex to seperate out half moves in chess to different capture groups from PGN files, to create a PGN viewer ( a chess game replayer) in JS :) I love regex now, it saved me so much headache :D
Hi..can someone help me on my problem...how can I sort, filter and set ranges columnwise on notepad ++.. I am struggling to find the right solution for this issue I am facing..thank you in advance..
Just watched this whole series and it was mind boggeling :) Thank you for teching me Regular expressions, and I've been coding so long, and now I dont know how I can have lived without RegEx... :D Anyways, one question or problem to solve. When parsing a text for hashtags (#) on social media, I found that this: /(#\w+)/g works for finding any word that starts with a hash, BUT it also finds hashes that you might have in a normal url with an anchor. I know these arent frequently used anymore, but still, Id like to not find hashes inside other texts. And no matter how many \b I use or where I cant get it to ignore those. Adding a \s first kinda works, but then messes up rows that begin with a hashtag: here it is in action: regexr.com/3fkmn
nice videos! Here's another example that I just came up with of what you could do with replace. let names = { Marian: "Superhero", John: "Rescuer", }; names = JSON.stringify(names); names = names.replace(/"(\w+)":/g, `"new$1":`); console.log(JSON.parse(names)["newJohn"]); Whut you can do that with javascript? Niceee :)) or this: let names = { Marian: 2, John: 3, }; names = JSON.stringify(names); console.log(names); names = names.replace(/:(\d+)/g, function () { return `:${arguments[1] * 2}`; }); What?? Ha ha this is too fun.
Those who have finished this guy's amazing Regular Expressions tutorial, Here is a good coding practice related to Regular Expressions from codewars! www.codewars.com/kata/valid-phone-number/train/javascript It's always good to try to implement skills you just learned and try to use them in order to solve something! Keep it up guys~
My idea is have large completely normal looking document. Each space after each word would represent either a “1” or a “zero “ depending whether there are one or two spaces there thus hiding your binary program in the document.
replace() with a function is very cool. I have used it in a Greasemonkey userscript that scans web pages for prices, and appends to them the price in your local currency: github.com/salty-horse/gm-scripts/blob/master/amazonLocalCurrency.user.js (It queries Yahoo's currency API once a day, and caches it in the greasemonkey registry) Other nice uses: 1) Rudimentary templating system (although Javascript now has template literals with backticks) 2) A simple way to escape text for inclusion in HTML. stackoverflow.com/a/1495837/16081 It's generally useful whenever you do several calls to replace in a row: new_str = replace().replace().replace()
I've never seen a teacher as happy as you! thanks for making these videos.
This guy has such a strong passion for teaching code that whatever he says just sticks to your brain without you even trying too hard.
very useful tutorials....I've spent 4 hours trying to solve a problem, after watching your video I solved it within 2 minutes !!!
just so people know, the number 15 at the end is not the groups added together, it is the index of where the match starts in the string. If you match the first character of the string, that index will be 0.
yeah, crazy how by accident it was the sum of the groups here too
Now that is useful.
One of those rare videos on the internet that I want to like twice.
Thank you!
myProfessors.replace(professor, Daniel Shiffman);
myProfessors.replace(/myProfessors/, "Daniel Shiffman"); Should work now
God, thank you for your service Stephen Curry!
No problem. Always here to help
You should be specialized on curying Stephen :)
You forgot the global flag
myProfessors.replace(/myProfessors/g, "Daniel Shiffman");
that was an amazing tutorial, i didn't even noticed that i'm watching the last one.
in few hours i watched all your videos and i'm so thankful to learn from you.
greetings from Syria
you are the best.
I wonder why are you so happy and super excited!!!!
I have a nice, simple application of applying functions for you:
Suppose you have a text with timestamps in 12 h (am/pm) notation. Your task is to convert them to 24 h notation. You may assume that all timestamps have this format: 9:30 AM, 12:30 PM, 1:11 PM, etc. This should then become 9:30, 12:30, 13:11.
I hope you like it! Converting AM to PM already is tricky.
This video just triggered a Eureka moment in my brain. I'm 35 and just started learning coding 4 months ago and I think I've just turned a corner. Thank u man. I'm not sure what u did, but it's like a fog has just lifted off of javascript for me.
I'm glad to hear!
this tutorial got me more excited than it is usually necessary
Year 2021, ES6 has Rest parameters. It's preferred over the arguments object. He refers to it as the arguments array. :)
This was a great video.
It's my first time to complete an entire tutorial in one day without feeling bored .. you're awesome ❤️
I'm sorry .. my English is not good 😅
Love hearing that, and your English is great!
yup I LOVE HIS TUTORIALS TOOO
Guy, you're my favorite programmer youtuber.
Thanks for helping me in this session so goodly.
Greetings from Brazil :D
DUDE,YOU ARE A LIFE SAVER
You're doing Gods work, Shiffman.
Just got to 2.9 and it's totally worth it! Thank you Daniel
Glad to hear!
Wow! I like Shiffman's enthusiasm!
Very usefull, now I finally can say that I've learned about RegEx whit your tutorials series. Thank you very much teacher Danniel, regards from Mexico :-). YOU ARE THE BEST!!!
The numbers 15, 109, and 166 seem to align with the first character of each of the "group zeros" searched. i.e. string[15] = 9 from "999-1324", string[109] = 1 from '111-8765', etc.
It's:
"The offset of the matched substring within the whole string being examined. (For example, if the whole string was 'abcd', and the matched substring was 'bc', then this argument will be 1.)"
Quoted from:
developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/replace
Daniel, why aren't you teaching how to read documentation? :) (I recommend pointing to MDN - Mozilla Developer Network, which is the best Javascript resource around. Even if it's not always super clear, it's a wiki and you can suggest changes).
Poking around a blackbox is fun, but you might reach wrong conclusions.
Having fun while doing regex :-) You're the best man in the world!
You are an amazing teacher. You're also mad and I love it! Please keep up the great videos!
*17:02*
_15 was the starting index of the first match. It was a coincidence resulting "15" to the total sum of lengths of the arguments inside a function_
6 years later this video still comes in handy
thank you Daniel, you change my life
15 is position of the matched number
is it possible to say I want regex to capture a,b and c, but replace a with a certain section of a, replace be with a certian section of b, and replace c with a certain section of c... I was thinking that | would be used in the match part of the replace , but I havent found a decent example
Thank you very much, you saved me the semester. excellent video
I've come back to watch this video so many times haha
Thanks, I think many coders struggle w/ regexp and could always use more help.
This guy made it look easy. Yesssssssiiiiirrrrrskiiiii
Just a quick question , Can i use wildcard somehow to manipulate text ??????
can substitution construct replace existing pattern to required pattern?
Hello, why does this work in splitting out numbers and text words per every capital letter?
userNameStructure: any;
const userName = '91MickeyMouse';
this.userNameStructure = userName.replace(/([a-z0-9])([A-Z])/g, '$1 $2');
console.log('words', this.userNameStructure);
RESULT: words 91 Mickey Mouse
My goal is to capture Mickey as first name, Mouse as last name. I was thinking I could call a function in place of '$1 $2', but that seems to fall apart.
I love your energy!
I used regex to seperate out half moves in chess to different capture groups from PGN files, to create a PGN viewer ( a chess game replayer) in JS :) I love regex now, it saved me so much headache :D
any advice how to split this string "n1->n2;n1->n3;goaln4;n4
What if I want to replace hypen from array of strings
Hi..can someone help me on my problem...how can I sort, filter and set ranges columnwise on notepad ++.. I am struggling to find the right solution for this issue I am facing..thank you in advance..
Thanks Buddy! You prevented me of converting 8k lines of code by myself.
Nice class dude! Does anyone know is he putting himself foreground and laptop's background? What is this software? Thanks !
Open Broadcast Studio and a green screen!
Thanks !!!!
If a content or file contains "some value".I mean string like something is "fishy". How you match or handle tat quotes data with regex???
I think those are literal characters so there's no need to do something special
5:24, absolutely out of his mind..
How would you change the regex without just redefining it?
Quite educative and exciting. What is createP?
how would you do replace anything after "..."
It is fun and educating. Thank you )
Just watched this whole series and it was mind boggeling :) Thank you for teching me Regular expressions, and I've been coding so long, and now I dont know how I can have lived without RegEx... :D
Anyways, one question or problem to solve. When parsing a text for hashtags (#) on social media, I found that this: /(#\w+)/g works for finding any word that starts with a hash, BUT it also finds hashes that you might have in a normal url with an anchor. I know these arent frequently used anymore, but still, Id like to not find hashes inside other texts. And no matter how many \b I use or where I cant get it to ignore those. Adding a \s first kinda works, but then messes up rows that begin with a hashtag: here it is in action: regexr.com/3fkmn
Great question! I think \b probably doesn't work b/c a slash is maybe a valid word boundary. Maybe you could try \s or ^ (beginning of line)?
\B(\#\w+)\b should be the answer, but it doesn't solve the case; .......?#............
Thank you Minh, this actually seems to work much better! :)
how to store regular expression into sqlite?
Great series! Thanks!
hi can you tell me regular expression for how to replace tag with tag
Did you find this? I’m looking to replace
Did you find this? I’m looking to replace
Thnaks you very much sir.
We appreciate your efforts.
There is one query,
Plz tell me how I can avoid html tags while replacing text on html page.
Awesome, thanks!
Lovin P5.JS
❤️❤️❤️❤️❤️👍👍👍👍
This is very delicious what we learn here. 👨💻😋
Exactly what I have needed.
man you are hilarious hahaha 😂
Love ur class :D
Write down Regular Expressions that can extract Strings 123.jpg and 432.png from
String axhdsjk123.jpg.jpg and hjhsd432.png.png
How to?
pls sir give me code for ana phora resolution in python
it is perfect 💥
great vid :D, it's fun
In atom there is a setting under the tab "Editor" which allows "Scroll Past End"
OMG! This is useful!
I would like to see you in strict mode
Impossible!
I thought to be quite good with RegExp but I didn't know about the lil secret of capturing group with split...
nice videos! Here's another example that I just came up with of what you could do with replace. let names = {
Marian: "Superhero",
John: "Rescuer",
};
names = JSON.stringify(names);
names = names.replace(/"(\w+)":/g, `"new$1":`);
console.log(JSON.parse(names)["newJohn"]);
Whut you can do that with javascript? Niceee :)) or this:
let names = {
Marian: 2,
John: 3,
};
names = JSON.stringify(names);
console.log(names);
names = names.replace(/:(\d+)/g, function () {
return `:${arguments[1] * 2}`;
});
What?? Ha ha this is too fun.
this is awesome 😂
REGEX! Baaaaybeeeeeeee yayaaah! :-)
Regex.Replace("ThisIsACamelCaseString", "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 ") explain this code please
can you plz explain it?Please
Those who have finished this guy's amazing Regular Expressions tutorial,
Here is a good coding practice related to Regular Expressions from codewars!
www.codewars.com/kata/valid-phone-number/train/javascript
It's always good to try to implement skills you just learned and try to use them in order to solve something!
Keep it up guys~
My idea is have large completely normal looking document. Each space after each word would represent either a “1” or a “zero “ depending whether there are one or two spaces there thus hiding your binary program in the document.
This dude has way less views than he deserves... Imma help U out and push your channel among my geek friends :)
replace() with a function is very cool. I have used it in a Greasemonkey userscript that scans web pages for prices, and appends to them the price in your local currency:
github.com/salty-horse/gm-scripts/blob/master/amazonLocalCurrency.user.js
(It queries Yahoo's currency API once a day, and caches it in the greasemonkey registry)
Other nice uses:
1) Rudimentary templating system (although Javascript now has template literals with backticks)
2) A simple way to escape text for inclusion in HTML. stackoverflow.com/a/1495837/16081
It's generally useful whenever you do several calls to replace in a row: new_str = replace().replace().replace()
The origin of the kittens song!
You can also use replace() with a string instead of a regular expression
I am the poor person watching it in the future😂😂😂,Thanks sir, understood clearly
me at my grandma's house 5:23
Thank u
Sorry no thumbs down :)
Wow, Dan knows Jenny too!
Kittens and kittens and kittens and kittens and kittens.... 😍 Kittens and rainbows and cupcakes 😂
What's to be excited about? yes regular expressions 😉
'It replaced everything with blueberry. But do you realise whats now possible?'
So the takeaway for me after this series of videos... RegEx is easy to write, yet difficult to read.
thanks,
I wonder how many people catch the 867 5309 ref
there is chocolate and beer i guess
No surprise someone did make it into a song. Check soundcloud
Nice 127 Likes and 0 Dislikes.
Difference between $1 and /1
The comments were 101 but I'm evil
kittens and kittens and kittens.....😂🤣
lol
leprechauns