Community
    • Login

    How to Remove unwanted space in Row After 4 Number?

    Scheduled Pinned Locked Moved General Discussion
    9 Posts 5 Posters 1.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jinko SolarJ
      Jinko Solar
      last edited by

      How to Remove unwanted space in Row After 4 Number? Like this,
      0300 8229386
      0300 8253137
      0334 0210214
      0300 2692165

      03008229386
      03008253137
      03340210214
      03002692165

      Please help us?

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Jinko Solar
        last edited by

        @Jinko-Solar

        Not sure enough info has been provided to solve the complete problem, but try this against the sample data…maybe it will give you enough hints for the “bigger” problem:

        FInd ((^\d+.+\R){4})\R
        Repl \1
        Mode Regular expression

        1 Reply Last reply Reply Quote 2
        • Jinko SolarJ
          Jinko Solar
          last edited by

          Sir, Sorry. It didn’t work.

          Meta ChuhM Alan KilbornA 2 Replies Last reply Reply Quote 0
          • Meta ChuhM
            Meta Chuh moderator @Jinko Solar
            last edited by

            @Jinko-Solar

            try this on your given example:

            find what: ^(\d+)(\s+)(.+)
            replace with: $1$3
            search mode: regular expression

            and hit replace all

            1 Reply Last reply Reply Quote 2
            • Alan KilbornA
              Alan Kilborn @Jinko Solar
              last edited by

              @Jinko-Solar said:

              Sir, Sorry. It didn’t work.

              Oh yes it does. I could record a screencast of it working but it isn’t worth my time. :)

              1 Reply Last reply Reply Quote 1
              • guy038G
                guy038
                last edited by

                Hello, @jinko-solar, @alan-kilborn,@meta-chuh, and All,

                Here is a third solution :

                SEARCH ^(\d+)\h*

                REPLACE $1


                Regarding your regex S/R, Alan :

                SEARCH ((^\d+.+\R){4})\R

                REPLACE \1

                I don’t mean to be rude, but this regex S/R really does not work ! You’ve certainly found out a new version, afterwards ;-))

                Best Regards,

                guy038

                Alan KilbornA 1 Reply Last reply Reply Quote 2
                • Alan KilbornA
                  Alan Kilborn @guy038
                  last edited by

                  @guy038

                  I don’t mean to be rude

                  No worries. Hmmm, it worked in RegexBuddy with all the same settings as Notepad++. I don’t think I’ve encountered a regex that works differently, so I didn’t check it in both, originally. But you are right, it won’t work in Notepad++. Moving the ^ to the very start outside the opening ( will work, however. I wonder what the difference is…

                  1 Reply Last reply Reply Quote 3
                  • PeterJonesP
                    PeterJones
                    last edited by PeterJones

                    @guy038 said:

                    [Alan’s] regex S/R really does not work

                    I think I see what happened: based on the behavior of @Alan-Kilborn’s regex: I think he interpreted the request as “remove the blank line (ie, vertical space) after four rows that start with numbers”, which would be a reasonable interpretation of the OP’s phrasing. @Meta-Chuh and @guy038 both came up with regex that removed a horizontal space after four digits in a given row.

                    Unfortunately, since @Jinko-Solar hasn’t chimed back in, we don’t yet know whether Meta or Guy got it right, either.

                    edit: simulpost: I may have interpreted Alan’s intention wrong…

                    1 Reply Last reply Reply Quote 2
                    • guy038G
                      guy038
                      last edited by

                      Hi, @jinko-solar, @alan-kilborn,@meta-chuh, @peterjones and All,

                      Aaaaaaaaah I see ! Just the way to interpret the OP’s request !

                      So, Alan, rest assured, your regex S/R is working as expected !

                      Assumming the text :

                      0300 8229386
                      0300 8253137
                      0334 0210214
                      0300 2692165
                      
                      03008229386
                      03008253137
                      03340210214
                      03002692165
                      

                      The regex S/R, below :

                      SEARCH ((^\d+.+\R){4})\R      OR       ^((\d+.+\R){4})\R

                      REPLACE \1

                      will leave you with the text :

                      0300 8229386
                      0300 8253137
                      0334 0210214
                      0300 2692165
                      03008229386
                      03008253137
                      03340210214
                      03002692165
                      

                      Cheers,

                      guy038

                      1 Reply Last reply Reply Quote 2
                      • First post
                        Last post
                      The Community of users of the Notepad++ text editor.
                      Powered by NodeBB | Contributors