• Login
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.
  • J
    Jinko Solar
    last edited by Apr 20, 2019, 12:36 PM

    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?

    A 1 Reply Last reply Apr 20, 2019, 12:46 PM Reply Quote 0
    • A
      Alan Kilborn @Jinko Solar
      last edited by Apr 20, 2019, 12:46 PM

      @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
      • J
        Jinko Solar
        last edited by Apr 22, 2019, 6:02 AM

        Sir, Sorry. It didn’t work.

        M A 2 Replies Last reply Apr 22, 2019, 7:58 AM Reply Quote 0
        • M
          Meta Chuh moderator @Jinko Solar
          last edited by Apr 22, 2019, 7:58 AM

          @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
          • A
            Alan Kilborn @Jinko Solar
            last edited by Apr 22, 2019, 1:03 PM

            @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
            • G
              guy038
              last edited by Apr 22, 2019, 9:24 PM

              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

              A 1 Reply Last reply Apr 22, 2019, 9:54 PM Reply Quote 2
              • A
                Alan Kilborn @guy038
                last edited by Apr 22, 2019, 9:54 PM

                @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
                • P
                  PeterJones
                  last edited by PeterJones Apr 22, 2019, 9:59 PM Apr 22, 2019, 9:57 PM

                  @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
                  • G
                    guy038
                    last edited by Apr 23, 2019, 1:26 AM

                    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
                    5 out of 9
                    • First post
                      5/9
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors