How can I remove all whitespace and carriage returns from a string? [duplicate]












0
















This question already has an answer here:




  • Remove ALL white spaces from text [duplicate]

    2 answers




I have string which is returning this to me:



<div class="sqs-layout sqs-grid-12 columns-12" data-layout-label="Post Body" data-type="item" data-updated-on="1539277027193" id="item-5bbf7e3f9140b70d3962e2a0"><div class="row sqs-row"><div class="col sqs-col-12 span-12"><div class="sqs-block image-block sqs-block-image" data-block-type="5" id="block-yui_3_17_2_1_1539794362468_25479"><div class="sqs-block-content">nn  nn  tn      <div class="image-block-outer-wrapper">


Any idea how I can remove all the whitespaces and put this into a JS variable? I have tried countless variations of this:



.replace(/[ntr]/g,"")


but nothing working yet...










share|improve this question















marked as duplicate by Liam, Icepickle, cнŝdk, chazsolo, The fourth bird Nov 16 '18 at 17:13


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1





    Why does it matter, purily out of curiousity? Can't you just change the source of the data, instead of fighting the symptoms?

    – Icepickle
    Nov 16 '18 at 13:29






  • 1





    Try s for whitespace.

    – Bernhard
    Nov 16 '18 at 13:30











  • @Icepickle it's Squarespace so can't do anything about the data output...

    – dwinnbrown
    Nov 16 '18 at 13:34











  • Did you check trim function of lodash lodash.com/docs/4.17.11#trim

    – Ahmet Tanakol
    Nov 16 '18 at 13:34











  • @Bernhard no luck I'm afraid

    – dwinnbrown
    Nov 16 '18 at 13:35
















0
















This question already has an answer here:




  • Remove ALL white spaces from text [duplicate]

    2 answers




I have string which is returning this to me:



<div class="sqs-layout sqs-grid-12 columns-12" data-layout-label="Post Body" data-type="item" data-updated-on="1539277027193" id="item-5bbf7e3f9140b70d3962e2a0"><div class="row sqs-row"><div class="col sqs-col-12 span-12"><div class="sqs-block image-block sqs-block-image" data-block-type="5" id="block-yui_3_17_2_1_1539794362468_25479"><div class="sqs-block-content">nn  nn  tn      <div class="image-block-outer-wrapper">


Any idea how I can remove all the whitespaces and put this into a JS variable? I have tried countless variations of this:



.replace(/[ntr]/g,"")


but nothing working yet...










share|improve this question















marked as duplicate by Liam, Icepickle, cнŝdk, chazsolo, The fourth bird Nov 16 '18 at 17:13


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1





    Why does it matter, purily out of curiousity? Can't you just change the source of the data, instead of fighting the symptoms?

    – Icepickle
    Nov 16 '18 at 13:29






  • 1





    Try s for whitespace.

    – Bernhard
    Nov 16 '18 at 13:30











  • @Icepickle it's Squarespace so can't do anything about the data output...

    – dwinnbrown
    Nov 16 '18 at 13:34











  • Did you check trim function of lodash lodash.com/docs/4.17.11#trim

    – Ahmet Tanakol
    Nov 16 '18 at 13:34











  • @Bernhard no luck I'm afraid

    – dwinnbrown
    Nov 16 '18 at 13:35














0












0








0









This question already has an answer here:




  • Remove ALL white spaces from text [duplicate]

    2 answers




I have string which is returning this to me:



<div class="sqs-layout sqs-grid-12 columns-12" data-layout-label="Post Body" data-type="item" data-updated-on="1539277027193" id="item-5bbf7e3f9140b70d3962e2a0"><div class="row sqs-row"><div class="col sqs-col-12 span-12"><div class="sqs-block image-block sqs-block-image" data-block-type="5" id="block-yui_3_17_2_1_1539794362468_25479"><div class="sqs-block-content">nn  nn  tn      <div class="image-block-outer-wrapper">


Any idea how I can remove all the whitespaces and put this into a JS variable? I have tried countless variations of this:



.replace(/[ntr]/g,"")


but nothing working yet...










share|improve this question

















This question already has an answer here:




  • Remove ALL white spaces from text [duplicate]

    2 answers




I have string which is returning this to me:



<div class="sqs-layout sqs-grid-12 columns-12" data-layout-label="Post Body" data-type="item" data-updated-on="1539277027193" id="item-5bbf7e3f9140b70d3962e2a0"><div class="row sqs-row"><div class="col sqs-col-12 span-12"><div class="sqs-block image-block sqs-block-image" data-block-type="5" id="block-yui_3_17_2_1_1539794362468_25479"><div class="sqs-block-content">nn  nn  tn      <div class="image-block-outer-wrapper">


Any idea how I can remove all the whitespaces and put this into a JS variable? I have tried countless variations of this:



.replace(/[ntr]/g,"")


but nothing working yet...





This question already has an answer here:




  • Remove ALL white spaces from text [duplicate]

    2 answers








javascript regex






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 16 '18 at 13:40









Liam

16.1k1676129




16.1k1676129










asked Nov 16 '18 at 13:26









dwinnbrowndwinnbrown

96931643




96931643




marked as duplicate by Liam, Icepickle, cнŝdk, chazsolo, The fourth bird Nov 16 '18 at 17:13


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Liam, Icepickle, cнŝdk, chazsolo, The fourth bird Nov 16 '18 at 17:13


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1





    Why does it matter, purily out of curiousity? Can't you just change the source of the data, instead of fighting the symptoms?

    – Icepickle
    Nov 16 '18 at 13:29






  • 1





    Try s for whitespace.

    – Bernhard
    Nov 16 '18 at 13:30











  • @Icepickle it's Squarespace so can't do anything about the data output...

    – dwinnbrown
    Nov 16 '18 at 13:34











  • Did you check trim function of lodash lodash.com/docs/4.17.11#trim

    – Ahmet Tanakol
    Nov 16 '18 at 13:34











  • @Bernhard no luck I'm afraid

    – dwinnbrown
    Nov 16 '18 at 13:35














  • 1





    Why does it matter, purily out of curiousity? Can't you just change the source of the data, instead of fighting the symptoms?

    – Icepickle
    Nov 16 '18 at 13:29






  • 1





    Try s for whitespace.

    – Bernhard
    Nov 16 '18 at 13:30











  • @Icepickle it's Squarespace so can't do anything about the data output...

    – dwinnbrown
    Nov 16 '18 at 13:34











  • Did you check trim function of lodash lodash.com/docs/4.17.11#trim

    – Ahmet Tanakol
    Nov 16 '18 at 13:34











  • @Bernhard no luck I'm afraid

    – dwinnbrown
    Nov 16 '18 at 13:35








1




1





Why does it matter, purily out of curiousity? Can't you just change the source of the data, instead of fighting the symptoms?

– Icepickle
Nov 16 '18 at 13:29





Why does it matter, purily out of curiousity? Can't you just change the source of the data, instead of fighting the symptoms?

– Icepickle
Nov 16 '18 at 13:29




1




1





Try s for whitespace.

– Bernhard
Nov 16 '18 at 13:30





Try s for whitespace.

– Bernhard
Nov 16 '18 at 13:30













@Icepickle it's Squarespace so can't do anything about the data output...

– dwinnbrown
Nov 16 '18 at 13:34





@Icepickle it's Squarespace so can't do anything about the data output...

– dwinnbrown
Nov 16 '18 at 13:34













Did you check trim function of lodash lodash.com/docs/4.17.11#trim

– Ahmet Tanakol
Nov 16 '18 at 13:34





Did you check trim function of lodash lodash.com/docs/4.17.11#trim

– Ahmet Tanakol
Nov 16 '18 at 13:34













@Bernhard no luck I'm afraid

– dwinnbrown
Nov 16 '18 at 13:35





@Bernhard no luck I'm afraid

– dwinnbrown
Nov 16 '18 at 13:35












1 Answer
1






active

oldest

votes


















1














You have to assign the value after the replace to another variable or the same variable. This is because strings are immutable. Also add s on the regex pattern.



var a = "nn  nn  tn      "
var b = a.replace(/[ntrs]/g, '');

//now b = "" and a still is "nn nn tn "
a = a.replace(/[ntrs]/g, ''); // this also work





share|improve this answer
































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    You have to assign the value after the replace to another variable or the same variable. This is because strings are immutable. Also add s on the regex pattern.



    var a = "nn  nn  tn      "
    var b = a.replace(/[ntrs]/g, '');

    //now b = "" and a still is "nn nn tn "
    a = a.replace(/[ntrs]/g, ''); // this also work





    share|improve this answer






























      1














      You have to assign the value after the replace to another variable or the same variable. This is because strings are immutable. Also add s on the regex pattern.



      var a = "nn  nn  tn      "
      var b = a.replace(/[ntrs]/g, '');

      //now b = "" and a still is "nn nn tn "
      a = a.replace(/[ntrs]/g, ''); // this also work





      share|improve this answer




























        1












        1








        1







        You have to assign the value after the replace to another variable or the same variable. This is because strings are immutable. Also add s on the regex pattern.



        var a = "nn  nn  tn      "
        var b = a.replace(/[ntrs]/g, '');

        //now b = "" and a still is "nn nn tn "
        a = a.replace(/[ntrs]/g, ''); // this also work





        share|improve this answer















        You have to assign the value after the replace to another variable or the same variable. This is because strings are immutable. Also add s on the regex pattern.



        var a = "nn  nn  tn      "
        var b = a.replace(/[ntrs]/g, '');

        //now b = "" and a still is "nn nn tn "
        a = a.replace(/[ntrs]/g, ''); // this also work






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 16 '18 at 14:13

























        answered Nov 16 '18 at 14:00









        atiqorinatiqorin

        764




        764















            Popular posts from this blog

            鏡平學校

            ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

            Why https connections are so slow when debugging (stepping over) in Java?