In this video, I cover the JavaScript function replace(). The function allows you to search for a string (by matching a regular expression) and replace that string. The replacement can be a literal string itself or you can pass in a callback where you can use logic and programming to generate a replacement string based on anything you can imagine.
This is the ninth video in a series on Regular Expressions, which is part of the “Programming from A to Z” course at ITP (
Next Video:
Course url:
Support this channel on Patreon:
Send me your questions and coding challenges!:
Contact:
GitHub Repo with all the info for Programming from A to Z:
Links discussed in this video:
MDN’s Regular Expressions Reference:
Regular Expressions on Wikipedia:
Book Mastering Regular Expressions:
ITP from Tisch School of the Arts:
Source Code for the all Video Lessons:
p5.js:
Processing:
For More Programming from A to Z videos:
For More Coding Challenges:
Help us caption & translate this video!
? Code of Conduct:
Nguồn:https://wijstaanvooronzegrondrechten.org/
Xem Thêm Bài Viết Khác:https://wijstaanvooronzegrondrechten.org/cong-nghe
Guy, you're my favorite programmer youtuber.
Thanks for helping me in this session so goodly.
Greetings from Brazil 😀
'It replaced everything with blueberry. But do you realise whats now possible?'
Those who have finished this guy's amazing Regular Expressions tutorial,
Here is a good coding practice related to Regular Expressions from codewars!
https://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~
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 😀
Write down Regular Expressions that can extract Strings 123.jpg and 432.png from
String axhdsjk123.jpg.jpg and hjhsd432.png.png
How to?
Here's a useful way to get a Date object easily using RegExp.
function getDate (str) {
const matcher = /d{1,2}-d{1,2}-d{4}/;
const match = matcher.exec(str);
return new Date(match[3], match[2], match[1]);
}
I've never seen a teacher as happy as you! thanks for making these videos.
It is possible to make a calculator with this regex:
/(d+)([-+*/%])(d+)/g
I've come back to watch this video so many times haha
there is chocolate and beer i guess
Kittens and kittens and kittens and kittens and kittens…. ? Kittens and rainbows and cupcakes ?
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!!!
You're doing Gods work, Shiffman.
pls sir give me code for ana phora resolution in python
this is awesome ?
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 would like to see you in strict mode
OMG! This is useful!
very useful tutorials….I've spent 4 hours trying to solve a problem, after watching your video I solved it within 2 minutes !!!
function imprim(){
var t5= ''
ctx.font = "Arial 14px"
positionY= 50
while( count< canvas.height/2){
ctx.fillText(t1,200,positionY)
positionY= positionY + 10
count = count +1}
function replace(t1){
var t5 = t1.replace(/t1/g,"php")
}
var t1= ' Hello javascript'
undefined
var t2= t1[3]
undefined
var t3 = t1.length
undefined
count=0
0
help me please
So the takeaway for me after this series of videos… RegEx is easy to write, yet difficult to read.
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
how to store regular expression into sqlite?
You can also use replace() with a string instead of a regular expression
Thank God I found this :*
2 minutes into the video and I found my error. Now THAT'S a good video 😀 bye
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.