Cut the divider and milliseconds in line Date by replace



  • There's a line. 2017-04-20T10:30:00.000Zreceived from the site Date. It's got to be cut off. Tand milliseconds from ZI mean, the last five symbols, including the point. What a regular expression fits here for. replace in javascript?



  • let rExp = /T|.{5}$/g;
    let sTxt = '2017-04-20T10:30:00.000Z';
    

    console.log( sTxt.replace(rExp, ' ').trim() );

    No. trim():

    let rExp = /([\d-]+)T([\d:]+).{5}$/g;
    let sTxt = '2017-04-20T10:30:00.000Z';

    console.log( sTxt.replace(rExp, '$1 $2') );



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2