• Login
Community
  • Login

How to separate two numbers from text?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 4 Posters 726 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.
  • F
    Faisal Alam
    last edited by Dec 25, 2020, 1:53 AM

    How can i join two lines which both have numbers. Try to comprehend with the example given below.

    What I’m having:

    54550 4208447963
    61186 7209982947
    59758 1765530261
    61538 7471871654
    24183 1399048005
    19948 6120524833
    55827 7214076491
    30842 9488550056
    32526 4053135693
    34275 8992850129
    

    What I want:

    54550
    4208447963
    61186
    7209982947
    59758
    1765530261
    61538
    7471871654
    24183
    1399048005
    19948
    6120524833
    55827
    7214076491
    30842
    9488550056
    32526
    4053135693
    34275
    8992850129
    

    These are adjacent lines.
    Please note: 1st line’s number is a constant 5 digit numeric value on the other hand the 2nd line’s number may change its digits in between 8 to 14 digits

    E 1 Reply Last reply Dec 25, 2020, 12:27 PM Reply Quote 0
    • G
      guy038
      last edited by guy038 Dec 25, 2020, 11:55 AM Dec 25, 2020, 11:49 AM

      Hello, @faisal-alam and All,

      You said :

      How can i join two lines which both have numbers.

      These are adjacent lines.

      Please note: 1st line’s number is a constant 5 digit numeric value on the other hand the 2nd line’s number may change its digits in between 8 to 14 digits

      In that case, the following regex S/R should solve your problem, very closely :

      SEARCH (?<=^\d{5})\x20(?=\d{8,14}(\R))

      REPLACE \1

      Important : You must click on the Replace All button, exclusively ( do not use the Replace button )


      Notes :

      • It searches for a space character \x20 , ONLY IF

        • Preceded with five digits \d{5} , exactly, beginning a line ^

        • Followed with a number between eight and fourteen digits \d{8,14} , ending the line \R

      • The line break chars are stored as group 1 due to the (\R) syntax

      • In replacement, the space char is, then, changed into the usual like-break of your file \1 ( the group 1 )

      Regards,

      guy038

      1 Reply Last reply Reply Quote 3
      • E
        Ekopalypse @Faisal Alam
        last edited by Dec 25, 2020, 12:27 PM

        @Faisal-Alam

        one alternative way might be to use the BetterMultiSelection plugin.

        1 Reply Last reply Reply Quote 4
        • A
          Alan Kilborn
          last edited by Dec 25, 2020, 12:42 PM

          Do we just keep answering this person’s trivial data manipulations forever? Or do we request that said person start learning so that we can pursue more interesting things on this forum?

          E 1 Reply Last reply Dec 25, 2020, 1:12 PM Reply Quote -1
          • E
            Ekopalypse @Alan Kilborn
            last edited by Dec 25, 2020, 1:12 PM

            I know it can be frustrating to give help in the hope that one will learn from it.
            On the other hand, it may be nice for those who answer to be able to do so. Helper syndrome.
            Honestly, I didn’t question whether the OP had already asked several of these questions,
            but just thought, hey, this can be done easily without regex.
            In the end, however, I am of the opinion that those who want to give answers should be allowed to do so.

            A 1 Reply Last reply Dec 25, 2020, 1:25 PM Reply Quote 1
            • A
              Alan Kilborn @Ekopalypse
              last edited by Alan Kilborn Dec 25, 2020, 1:26 PM Dec 25, 2020, 1:25 PM

              @Ekopalypse said in How to separate two numbers from text?:

              but just thought, hey, this can be done easily without regex.

              Yes and you present a good technique, something interesting to the forum.

              those who want to give answers should be allowed to do so

              Surely, and I can’t stop them.
              Just my efforts to keep us on track, and not being a continual back-and-forth data translation service for those that don’t choose to go off and learn how to do their own, with the basics given here.

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