Delete two characters but not from all columns

  • 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.

  • @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.

  • @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
    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.


  • @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.

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

Log in to reply