Using the String.replace() method - JavaScript Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ต.ค. 2024
  • In today's video I'll be demonstrating the use of the String.replace() method within JavaScript including covering it's more advanced usage. This includes regular expressions, capture groups and using a function as the third parameter.
    Support me on Patreon:
    / dcode - with enough funding I plan to develop a website of some sort with a new developer experience!
    For your reference, check this out:
    developer.mozi...
    Follow me on Twitter @dcodeyt!
    If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
    #dcode #javascript #webdev

ความคิดเห็น • 28

  • @smoothbeak
    @smoothbeak 4 ปีที่แล้ว +7

    So, tell me about your thing for older women. :P

  • @anubhav3954
    @anubhav3954 4 ปีที่แล้ว +1

    Can make a feed back form of the user**** that actually we can see.**** If we can please make a tutorial on it****
    ****Only html css and java script

  • @leonardmbibi8013
    @leonardmbibi8013 2 ปีที่แล้ว +1

    Thanks for your video though it will take someone with sound knowledge of RegEx or quite brilliant to understand you. 😁

  • @kikevanegazz325
    @kikevanegazz325 3 ปีที่แล้ว +1

    I was an excellent video, but I would have liked to see you grouping up a string with no numerical value. I mean, no numbers in it. If you could tell me how, I'd appreciate it.

  • @ruebenhales8558
    @ruebenhales8558 2 ปีที่แล้ว

    no clue how \d+ equals the first number?

  • @junaidsalih4022
    @junaidsalih4022 4 ปีที่แล้ว +1

    another amazing video. your youtube videos are better than your udemy class. Why you are not making a professional class on HTML, CSS and Javascript on udemy

  • @keithvaneaton5840
    @keithvaneaton5840 2 ปีที่แล้ว

    This is nice, but not very practical, can you show an example of removing a reoccurring section of text/string from within an array of objects? Example [{ page: { results: [{ title: 'keep this - textI dont want' }, {keep this - difftextI dont want}, {keep this - diffdifftextI dont want} ]}}]

  • @squeegeul2.033
    @squeegeul2.033 3 ปีที่แล้ว +1

    6:15 uhhhh hey, i'm 31 and she's 21 $!

  • @mervinlee450
    @mervinlee450 4 ปีที่แล้ว +1

    Hello! How do you get rid of everything after a semicolon?

  • @Louis-kr6of
    @Louis-kr6of 4 ปีที่แล้ว +2

    Hello, is there an easy way to replace some text from a string to an html tag ?
    Thank you in advance for your answer :)

    • @colindante5164
      @colindante5164 2 ปีที่แล้ว +1

      let newPhrase = document.querySelector(".phrase");
      let myString = "Wrap Html Tags around this string of text";
      let textFragment = myString.replace(/html tags/gi, () => {
      return `YOUR MIND`;
      });
      newPhrase.innerHTML = textFragment;
      // The output would read "Wrap YOUR MIND around this string of text"
      // Note that "YOUR MIND" is italicised

  • @PatrickLimitless
    @PatrickLimitless 2 ปีที่แล้ว

    Did not know about console.log(arguments). Very useful

  • @DanielCalleCO
    @DanielCalleCO 2 ปีที่แล้ว

    Finnaly I understood how to replace a lot of letters from my strip. THANKS a lot and greetings from Colombia.

  • @smoothbeak
    @smoothbeak 4 ปีที่แล้ว +1

    A regular expressions video would be nice

  • @swastikbhardwaj184
    @swastikbhardwaj184 4 ปีที่แล้ว +1

    Your videos are very helpful.

  • @sodiumsulfur2779
    @sodiumsulfur2779 3 ปีที่แล้ว

    Why TH-cam didn't remove outline for the "Like" button ?!?!?!?

  • @СашаТюменцев-ш9ь
    @СашаТюменцев-ш9ь 2 ปีที่แล้ว

    thanks

  • @karenkharatyan1
    @karenkharatyan1 4 ปีที่แล้ว +1

    Awesome stuff!

  • @monsterminer5831
    @monsterminer5831 2 ปีที่แล้ว

    Hi ! Whats the point of the plus sign after the d?

  • @_.sunnyraj._
    @_.sunnyraj._ 4 ปีที่แล้ว

    Never HEard of this

  • @emmanuelrf
    @emmanuelrf 4 ปีที่แล้ว

    Waiting for the RegEx series! 🙌🏼🙌🏼🙌🏼

  • @madanmitra2530
    @madanmitra2530 2 ปีที่แล้ว

    superb vdo thank you

  • @altrae
    @altrae ปีที่แล้ว

    Instead of using parseInt at the end you could also use a template literal: return `${g1 + g3}` or if you want it to use the groups to make more sense to the reader: return `${g3} ${g2} ${g1 + g3}`. Also, if you don't need to print the arguments you can convert your function to an arrow function making it more concise: console.log(myStr.replace(/(\d+)([^\d]+)(\d+)/g, (match, g1, g2, g3) => `${g3} ${g2} ${g1 + g3}`));
    :)

  • @rangabharath4253
    @rangabharath4253 4 ปีที่แล้ว

    awesome

  • @reclearning558
    @reclearning558 4 ปีที่แล้ว

    Really good video

  • @elusion9387
    @elusion9387 2 ปีที่แล้ว

    great vif