Regex: Select empty spaces from a particular tab and replace them with one single space [duplicate]












0
















This question already has an answer here:




  • Regex: Remove every two or more spaces between specific tags and leave just a space instead

    3 answers




hello and Happy new year !



have a little problem with more then 2000 .html files. I need to select all empty spaces from the next particular tag, and to replace with just one space.



<p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>



My regex is not very good :(



Search: (?s)(?:G)|<p class="text_formal">).*?|.*(?=</p>)|+h



Replace by: (Leave one space)










share|improve this question















marked as duplicate by harrymc, DavidPostill windows-10
Users with the  windows-10 badge can single-handedly close windows-10 questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Dec 31 '18 at 16:58


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.























    0
















    This question already has an answer here:




    • Regex: Remove every two or more spaces between specific tags and leave just a space instead

      3 answers




    hello and Happy new year !



    have a little problem with more then 2000 .html files. I need to select all empty spaces from the next particular tag, and to replace with just one space.



    <p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>



    My regex is not very good :(



    Search: (?s)(?:G)|<p class="text_formal">).*?|.*(?=</p>)|+h



    Replace by: (Leave one space)










    share|improve this question















    marked as duplicate by harrymc, DavidPostill windows-10
    Users with the  windows-10 badge can single-handedly close windows-10 questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Dec 31 '18 at 16:58


    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.





















      0












      0








      0









      This question already has an answer here:




      • Regex: Remove every two or more spaces between specific tags and leave just a space instead

        3 answers




      hello and Happy new year !



      have a little problem with more then 2000 .html files. I need to select all empty spaces from the next particular tag, and to replace with just one space.



      <p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>



      My regex is not very good :(



      Search: (?s)(?:G)|<p class="text_formal">).*?|.*(?=</p>)|+h



      Replace by: (Leave one space)










      share|improve this question

















      This question already has an answer here:




      • Regex: Remove every two or more spaces between specific tags and leave just a space instead

        3 answers




      hello and Happy new year !



      have a little problem with more then 2000 .html files. I need to select all empty spaces from the next particular tag, and to replace with just one space.



      <p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>



      My regex is not very good :(



      Search: (?s)(?:G)|<p class="text_formal">).*?|.*(?=</p>)|+h



      Replace by: (Leave one space)





      This question already has an answer here:




      • Regex: Remove every two or more spaces between specific tags and leave just a space instead

        3 answers








      windows-10 notepad++ regex






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 31 '18 at 17:08







      Rob Rob

















      asked Dec 31 '18 at 15:21









      Rob RobRob Rob

      32




      32




      marked as duplicate by harrymc, DavidPostill windows-10
      Users with the  windows-10 badge can single-handedly close windows-10 questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Dec 31 '18 at 16:58


      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 harrymc, DavidPostill windows-10
      Users with the  windows-10 badge can single-handedly close windows-10 questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Dec 31 '18 at 16:58


      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.
























          2 Answers
          2






          active

          oldest

          votes


















          1















          1. Select the part in which you want to make changes

          2. Ctrl+H

          3. Find what: + (space and plus sign)

          4. Replace with: (just space)

          5. Check In selection (or press Alt+I)

          6. Click on Replace all button (or press Alt+A)


          That's all :)






          share|improve this answer
























          • I have more then 2000 .html files. Cannot do this :)

            – Rob Rob
            Dec 31 '18 at 17:08











          • This will replace multiple spaces everywhere in the file. They want to replace ONLY inside <p..> ... </p>

            – Toto
            Dec 31 '18 at 17:35



















          0
















          • Ctrl+H

          • Find what: (?:^<p class="text_formal">|G)Ks*(S+)

          • Replace with: $1 # a space then $1

          • check Wrap around

          • check Regular expression

          • Replace all


          Explanation:



          (?:                             # start non capture group
          ^ # beginning of line
          <p class="text_formal"> # literally
          | # OR
          G # restart from last match position
          ) # end group
          K # forget all we have seen until this position
          s* # 0 or more spaces
          (S+) # group 1, 1 or more any character that is not a space


          Result for given example:



           <p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>





          share|improve this answer
























          • Toto, $1 # a space then $1 means $1 $1 ? Are you sure isnt it $1 $2 ? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines

            – Rob Rob
            Dec 31 '18 at 17:11













          • @RobRob: I mean the replacement part is a space followed by $1. Have a look at the duplicate question.

            – Toto
            Dec 31 '18 at 17:34











          • yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1

            – Rob Rob
            Dec 31 '18 at 17:44











          • @RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.

            – Toto
            Dec 31 '18 at 18:04











          • something about this will be more easily, if is possible: Search: <p class="test_formal">[^Srn]+(.*)</p> Replace by: (leave one space)

            – Rob Rob
            Jan 2 at 11:07


















          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1















          1. Select the part in which you want to make changes

          2. Ctrl+H

          3. Find what: + (space and plus sign)

          4. Replace with: (just space)

          5. Check In selection (or press Alt+I)

          6. Click on Replace all button (or press Alt+A)


          That's all :)






          share|improve this answer
























          • I have more then 2000 .html files. Cannot do this :)

            – Rob Rob
            Dec 31 '18 at 17:08











          • This will replace multiple spaces everywhere in the file. They want to replace ONLY inside <p..> ... </p>

            – Toto
            Dec 31 '18 at 17:35
















          1















          1. Select the part in which you want to make changes

          2. Ctrl+H

          3. Find what: + (space and plus sign)

          4. Replace with: (just space)

          5. Check In selection (or press Alt+I)

          6. Click on Replace all button (or press Alt+A)


          That's all :)






          share|improve this answer
























          • I have more then 2000 .html files. Cannot do this :)

            – Rob Rob
            Dec 31 '18 at 17:08











          • This will replace multiple spaces everywhere in the file. They want to replace ONLY inside <p..> ... </p>

            – Toto
            Dec 31 '18 at 17:35














          1












          1








          1








          1. Select the part in which you want to make changes

          2. Ctrl+H

          3. Find what: + (space and plus sign)

          4. Replace with: (just space)

          5. Check In selection (or press Alt+I)

          6. Click on Replace all button (or press Alt+A)


          That's all :)






          share|improve this answer














          1. Select the part in which you want to make changes

          2. Ctrl+H

          3. Find what: + (space and plus sign)

          4. Replace with: (just space)

          5. Check In selection (or press Alt+I)

          6. Click on Replace all button (or press Alt+A)


          That's all :)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 31 '18 at 16:17









          Grzegorz SuprynGrzegorz Supryn

          112




          112













          • I have more then 2000 .html files. Cannot do this :)

            – Rob Rob
            Dec 31 '18 at 17:08











          • This will replace multiple spaces everywhere in the file. They want to replace ONLY inside <p..> ... </p>

            – Toto
            Dec 31 '18 at 17:35



















          • I have more then 2000 .html files. Cannot do this :)

            – Rob Rob
            Dec 31 '18 at 17:08











          • This will replace multiple spaces everywhere in the file. They want to replace ONLY inside <p..> ... </p>

            – Toto
            Dec 31 '18 at 17:35

















          I have more then 2000 .html files. Cannot do this :)

          – Rob Rob
          Dec 31 '18 at 17:08





          I have more then 2000 .html files. Cannot do this :)

          – Rob Rob
          Dec 31 '18 at 17:08













          This will replace multiple spaces everywhere in the file. They want to replace ONLY inside <p..> ... </p>

          – Toto
          Dec 31 '18 at 17:35





          This will replace multiple spaces everywhere in the file. They want to replace ONLY inside <p..> ... </p>

          – Toto
          Dec 31 '18 at 17:35













          0
















          • Ctrl+H

          • Find what: (?:^<p class="text_formal">|G)Ks*(S+)

          • Replace with: $1 # a space then $1

          • check Wrap around

          • check Regular expression

          • Replace all


          Explanation:



          (?:                             # start non capture group
          ^ # beginning of line
          <p class="text_formal"> # literally
          | # OR
          G # restart from last match position
          ) # end group
          K # forget all we have seen until this position
          s* # 0 or more spaces
          (S+) # group 1, 1 or more any character that is not a space


          Result for given example:



           <p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>





          share|improve this answer
























          • Toto, $1 # a space then $1 means $1 $1 ? Are you sure isnt it $1 $2 ? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines

            – Rob Rob
            Dec 31 '18 at 17:11













          • @RobRob: I mean the replacement part is a space followed by $1. Have a look at the duplicate question.

            – Toto
            Dec 31 '18 at 17:34











          • yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1

            – Rob Rob
            Dec 31 '18 at 17:44











          • @RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.

            – Toto
            Dec 31 '18 at 18:04











          • something about this will be more easily, if is possible: Search: <p class="test_formal">[^Srn]+(.*)</p> Replace by: (leave one space)

            – Rob Rob
            Jan 2 at 11:07
















          0
















          • Ctrl+H

          • Find what: (?:^<p class="text_formal">|G)Ks*(S+)

          • Replace with: $1 # a space then $1

          • check Wrap around

          • check Regular expression

          • Replace all


          Explanation:



          (?:                             # start non capture group
          ^ # beginning of line
          <p class="text_formal"> # literally
          | # OR
          G # restart from last match position
          ) # end group
          K # forget all we have seen until this position
          s* # 0 or more spaces
          (S+) # group 1, 1 or more any character that is not a space


          Result for given example:



           <p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>





          share|improve this answer
























          • Toto, $1 # a space then $1 means $1 $1 ? Are you sure isnt it $1 $2 ? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines

            – Rob Rob
            Dec 31 '18 at 17:11













          • @RobRob: I mean the replacement part is a space followed by $1. Have a look at the duplicate question.

            – Toto
            Dec 31 '18 at 17:34











          • yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1

            – Rob Rob
            Dec 31 '18 at 17:44











          • @RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.

            – Toto
            Dec 31 '18 at 18:04











          • something about this will be more easily, if is possible: Search: <p class="test_formal">[^Srn]+(.*)</p> Replace by: (leave one space)

            – Rob Rob
            Jan 2 at 11:07














          0












          0








          0









          • Ctrl+H

          • Find what: (?:^<p class="text_formal">|G)Ks*(S+)

          • Replace with: $1 # a space then $1

          • check Wrap around

          • check Regular expression

          • Replace all


          Explanation:



          (?:                             # start non capture group
          ^ # beginning of line
          <p class="text_formal"> # literally
          | # OR
          G # restart from last match position
          ) # end group
          K # forget all we have seen until this position
          s* # 0 or more spaces
          (S+) # group 1, 1 or more any character that is not a space


          Result for given example:



           <p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>





          share|improve this answer















          • Ctrl+H

          • Find what: (?:^<p class="text_formal">|G)Ks*(S+)

          • Replace with: $1 # a space then $1

          • check Wrap around

          • check Regular expression

          • Replace all


          Explanation:



          (?:                             # start non capture group
          ^ # beginning of line
          <p class="text_formal"> # literally
          | # OR
          G # restart from last match position
          ) # end group
          K # forget all we have seen until this position
          s* # 0 or more spaces
          (S+) # group 1, 1 or more any character that is not a space


          Result for given example:



           <p class="test_formal"> This is my text <em>and all of this</em> I have to go home .</p>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 31 '18 at 16:04









          TotoToto

          3,763101226




          3,763101226













          • Toto, $1 # a space then $1 means $1 $1 ? Are you sure isnt it $1 $2 ? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines

            – Rob Rob
            Dec 31 '18 at 17:11













          • @RobRob: I mean the replacement part is a space followed by $1. Have a look at the duplicate question.

            – Toto
            Dec 31 '18 at 17:34











          • yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1

            – Rob Rob
            Dec 31 '18 at 17:44











          • @RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.

            – Toto
            Dec 31 '18 at 18:04











          • something about this will be more easily, if is possible: Search: <p class="test_formal">[^Srn]+(.*)</p> Replace by: (leave one space)

            – Rob Rob
            Jan 2 at 11:07



















          • Toto, $1 # a space then $1 means $1 $1 ? Are you sure isnt it $1 $2 ? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines

            – Rob Rob
            Dec 31 '18 at 17:11













          • @RobRob: I mean the replacement part is a space followed by $1. Have a look at the duplicate question.

            – Toto
            Dec 31 '18 at 17:34











          • yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1

            – Rob Rob
            Dec 31 '18 at 17:44











          • @RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.

            – Toto
            Dec 31 '18 at 18:04











          • something about this will be more easily, if is possible: Search: <p class="test_formal">[^Srn]+(.*)</p> Replace by: (leave one space)

            – Rob Rob
            Jan 2 at 11:07

















          Toto, $1 # a space then $1 means $1 $1 ? Are you sure isnt it $1 $2 ? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines

          – Rob Rob
          Dec 31 '18 at 17:11







          Toto, $1 # a space then $1 means $1 $1 ? Are you sure isnt it $1 $2 ? Can you make an example on regex101.com ? I don't think it is working. Besides, seems that the regex put all the lines in a single line. try regex on more same lines

          – Rob Rob
          Dec 31 '18 at 17:11















          @RobRob: I mean the replacement part is a space followed by $1. Have a look at the duplicate question.

          – Toto
          Dec 31 '18 at 17:34





          @RobRob: I mean the replacement part is a space followed by $1. Have a look at the duplicate question.

          – Toto
          Dec 31 '18 at 17:34













          yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1

          – Rob Rob
          Dec 31 '18 at 17:44





          yes, ok, the problem is that regex moves all lines on a single line. And, it is not select only the particular tab, but all tags :) regex101.com/r/ybSQFD/1

          – Rob Rob
          Dec 31 '18 at 17:44













          @RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.

          – Toto
          Dec 31 '18 at 18:04





          @RobRob: I can't do more, sorry. Look at the duplicate question. If it doesn't work, you have to write a script in your favorite scripting language.

          – Toto
          Dec 31 '18 at 18:04













          something about this will be more easily, if is possible: Search: <p class="test_formal">[^Srn]+(.*)</p> Replace by: (leave one space)

          – Rob Rob
          Jan 2 at 11:07





          something about this will be more easily, if is possible: Search: <p class="test_formal">[^Srn]+(.*)</p> Replace by: (leave one space)

          – Rob Rob
          Jan 2 at 11:07



          Popular posts from this blog

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          Origin of the phrase “under your belt”?