• Login
Community
  • Login

Delete two characters but not from all columns

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 3 Posters 884 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
    Farnoosh Aslami
    last edited by Oct 20, 2020, 9:33 PM

    Hello,
    I have large files, each includes more than one million rows, so I have to use Notepad++ instead of Excel for the first time! i intend to delete two characters (“12”) from the beginning of ONLY two columns, the first 12 started on 17th and the second 12 started on 53th position.
    I was said to use " 12(.+?(?= ))" and replace with " \1", it works well for the first seven columns, but in case of two last columns that have only two characters/values, the “12(.+?(?= ))” will delete all 12s from the 8th columns and make a mess in the last two columns. How can I fix it?
    a data row is like:

      669850.832160 12855334.50  6103459.08      912.04 12475334.50  6803459.08      812.06   12   10
    

    I would be appreciated if you could help.

    P 1 Reply Last reply Oct 20, 2020, 10:34 PM Reply Quote 0
    • P
      PeterJones @Farnoosh Aslami
      last edited by Oct 20, 2020, 10:34 PM

      @Farnoosh-Aslami ,

      In the future, please do not delete the old topic and create a new one about the same question – everyone has now lost the context of what’s already gone before. Just reply to the old topic with further information.

      F 1 Reply Last reply Oct 20, 2020, 10:42 PM Reply Quote 1
      • T
        Terry R
        last edited by Oct 20, 2020, 10:34 PM

        @Farnoosh-Aslami said in Delete two characters but not from all columns:

        the first 12 started on 17th and the second 12 started on 53th position.

        When I copied your example line there appeared to be a difference in the column numbers you supplied (17th and 53rd) and what the example line showed (I get 18th and 53rd for the 1 in each number, or 17th and 52nd if the position immediately before the 1). Because of that I looked at what your current regex does " 12(.+?(?= ))" to see if any adjustment (since it almost worked well enough) could help.
        I came up with
        \b12(\d+)
        and keeping the current replacement as \1

        So it will only capture if the 12 is at the start of a number and ONLY if it is followed by some more numbers. Since you only provide 1 example line there may be other issues. If so please provide more example lines, especially where it does NOT work.

        If you have issues then a regex (regular expression) could be provided that EXACTLY counts 18 (or 17) and 53 (or 52) and then provides for a replacement.

        Terry

        F 1 Reply Last reply Oct 20, 2020, 10:58 PM Reply Quote 2
        • F
          Farnoosh Aslami @PeterJones
          last edited by Oct 20, 2020, 10:42 PM

          @PeterJones sorry for any inconvenience… it was my first time and I was unfamiliar with posting a topic… wont be repeated. thanks for your attention.

          1 Reply Last reply Reply Quote 0
          • F
            Farnoosh Aslami @Terry R
            last edited by Oct 20, 2020, 10:58 PM

            @Terry-R OMG thanks a bunch Terry… It worked perfectly. You saved me!

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