2.9: Regular Expressions: replace() - Programming with Text

2.9: Regular Expressions: replace() - Programming with Text

The Coding Train

7 лет назад

75,652 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@user-ce3bb8qc1k
@user-ce3bb8qc1k - 30.09.2023 10:33

It is fun and educating. Thank you )

Ответить
@geoffwagner4935
@geoffwagner4935 - 08.06.2023 01:15

leprechauns

Ответить
@ebraheemuthman7733
@ebraheemuthman7733 - 12.11.2022 20:20

Quite educative and exciting. What is createP?

Ответить
@tentacle_sama3822
@tentacle_sama3822 - 10.11.2022 17:36

6 years later this video still comes in handy

Ответить
@motiurrahaman449
@motiurrahaman449 - 05.08.2022 23:54

kittens and kittens and kittens.....😂🤣

Ответить
@johnjackson3483
@johnjackson3483 - 01.06.2022 17:45

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.

Ответить
@hannahmarques3422
@hannahmarques3422 - 21.04.2022 22:15

Thank u

Ответить
@kentaylor6120
@kentaylor6120 - 23.03.2022 11:37

Lovin P5.JS

Ответить
@kentaylor6120
@kentaylor6120 - 23.03.2022 11:36

//Dragon lsystem Ken Taylor

dx=[0,2.5,0,-2.5];
dy=[2.5,0,-2.5,0];
dir=0;
count=0;
function setup() {
createCanvas(400, 600);
x=width*0.3
y=height*0.75
oldx=x;
oldy=y;
background(0);
a="FX"
for(i=0;i<12;i++){
a=a.replace( /F/g,"F+T");
a=a.replace(/f/g,"F-f");
a=a.replace(/T/g,"f");}}
function draw() {
if(a.charAt(count)=="+"){
dir++
if(dir==4){dir=0}}
if(a.charAt(count)=="-"){
dir--
if(dir==-1){dir=3}}
oldx=x;
oldy=y;
x+=dx[dir];
y+=dy[dir];
if(a.charAt(count)!="X"){
stroke(sin(count/50)*255,0,255-sin(count/50)*255);
line(x,y,oldx,oldy);
count++}}

Ответить
@aswinikonagalla4045
@aswinikonagalla4045 - 17.03.2022 15:10

hi can you tell me regular expression for how to replace <p> tag with <br> tag

Ответить
@dever312
@dever312 - 24.01.2022 21:12

This guy made it look easy. Yesssssssiiiiirrrrrskiiiii

Ответить
@marcohallister3966
@marcohallister3966 - 06.09.2021 10:33

Thanks Buddy! You prevented me of converting 8k lines of code by myself.

Ответить
@joelchacon9278
@joelchacon9278 - 20.08.2021 19:58

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.

Ответить
@federicotrotta968
@federicotrotta968 - 01.08.2021 22:52

I thought to be quite good with RegExp but I didn't know about the lil secret of capturing group with split...

Ответить
@yoho403
@yoho403 - 05.07.2021 23:12

how would you do replace anything after "..."

Ответить
@yuvaraj8922
@yuvaraj8922 - 23.06.2021 22:14

DUDE,YOU ARE A LIFE SAVER

Ответить
@Anderson-tm1sl
@Anderson-tm1sl - 27.04.2021 16:15

I love your energy!

Ответить
@techslugz
@techslugz - 15.04.2021 11:49

REGEX! Baaaaybeeeeeeee yayaaah! :-)

Ответить
@itcertifications6066
@itcertifications6066 - 29.03.2021 16:17

I wonder why are you so happy and super excited!!!!

Ответить
@programmingpi314
@programmingpi314 - 05.02.2021 02:57

How would you change the regex without just redefining it?

Ответить
@shaharle88
@shaharle88 - 23.01.2021 00:23

any advice how to split this string "n1->n2;n1->n3;goal<->n4;n4<-n1" to n1,n2,n3,n4,goal?

Ответить
@47-movies11
@47-movies11 - 30.11.2020 17:34

can you plz explain it?Please

Ответить
@47-movies11
@47-movies11 - 30.11.2020 17:33

can substitution construct replace existing pattern to required pattern?

Ответить
@DougKelleyDeveloperAccountant
@DougKelleyDeveloperAccountant - 09.11.2020 23:35

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.

Ответить
@TheCodingOdyssey
@TheCodingOdyssey - 08.11.2020 13:48

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.

Ответить
@nvmitsok
@nvmitsok - 17.10.2020 10:21

The comments were 101 but I'm evil

Ответить
@gnul
@gnul - 06.10.2020 06:27

❤️❤️❤️❤️❤️👍👍👍👍

This is very delicious what we learn here. 👨‍💻😋

Exactly what I have needed.

Ответить
@jakewood5475
@jakewood5475 - 20.09.2020 12:46

What's to be excited about? yes regular expressions 😉

Ответить
@happykhan299
@happykhan299 - 10.07.2020 16:43

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..

Ответить
@PedroEnriqueGutierrezNavarro
@PedroEnriqueGutierrezNavarro - 09.07.2020 06:55

Awesome, thanks!

Ответить
@KCWonderWorld
@KCWonderWorld - 26.06.2020 19:14

What if I want to replace hypen from array of strings

Ответить
@balaumar100
@balaumar100 - 07.06.2020 12:51

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???

Ответить
@guitarbits17
@guitarbits17 - 25.04.2020 15:36

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.

Ответить
@avitolourenco
@avitolourenco - 04.04.2020 20:30

Difference between $1 and /1

Ответить
@galaxyexpress5943
@galaxyexpress5943 - 23.02.2020 14:19

it is perfect 💥

Ответить
@emotionice7967
@emotionice7967 - 08.12.2019 00:08

'It replaced everything with blueberry. But do you realise whats now possible?'

Ответить
@apresthus87
@apresthus87 - 30.09.2019 03:24

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

Ответить
@noorfuadillah8927
@noorfuadillah8927 - 20.08.2019 07:07

Write down Regular Expressions that can extract Strings 123.jpg and 432.png from
String axhdsjk123.jpg.jpg and hjhsd432.png.png
How to?

Ответить
@thefreeze6023
@thefreeze6023 - 02.07.2019 16:26

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]);
}

Ответить
@nikhilbankar4412
@nikhilbankar4412 - 20.06.2019 16:26

I've never seen a teacher as happy as you! thanks for making these videos.

Ответить
@MM-pu8hc
@MM-pu8hc - 27.05.2019 20:53

It is possible to make a calculator with this regex:
/(\d+)([-+*/%])(\d+)/g

Ответить
@CameronChardukian
@CameronChardukian - 03.04.2019 16:15

I've come back to watch this video so many times haha

Ответить
@Spacecakesupreme
@Spacecakesupreme - 01.04.2019 17:56

there is chocolate and beer i guess

Ответить
@loic.bertrand
@loic.bertrand - 06.02.2019 02:44

Kittens and kittens and kittens and kittens and kittens.... 😍 Kittens and rainbows and cupcakes 😂

Ответить
@alexisarcegomez8698
@alexisarcegomez8698 - 04.02.2019 07:20

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!!!

Ответить