• Login
Community
  • Login

I need to delete anything before ANY number, AND the number in a line

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 3 Posters 1.1k 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.
  • G
    greg greg
    last edited by Apr 5, 2023, 8:30 AM

    I need to make this:

    Cobrança recebida - fatura nr. 183893434 JOÃO FLORES
    Taxa de boleto - fatura nr. 183893434 JOÃO FLORES
    Desconto na tarifa - fatura nr. 183893434 JOÃO FLORES
    Cobrança recebida - fatura nr. 184029355 JOÃO FLORES
    Taxa do Pix - fatura nr. 184029355 JOÃO FLORES
    Desconto na tarifa - fatura nr. 184029355 JOÃO FLORES
    Cobrança recebida - fatura nr. 184569951 Proredes Int C E Servicos De Inf
    Transação via Pix com chave para PRO INT SER DE INF
    Cobrança recebida - fatura nr. 185197278 RUDNALDO FERNANDES DIAS DA SILVA
    Taxa de boleto - fatura nr. 185197278 RUDNALDO FERNANDES DIAS DA SILVA
    Desconto na tarifa - fatura nr. 185197278 RUDNALDO FERNANDES DIAS DA SILVA

    Becoming this:

    JOÃO FLORES
    JOÃO FLORES
    JOÃO FLORES
    JOÃO FLORES
    JOÃO FLORES
    JOÃO FLORES
    Proredes Int C E Servicos De Inf
    PRO INT SER DE INF
    RUDNALDO FERNANDES DIAS DA SILVA
    RUDNALDO FERNANDES DIAS DA SILVA
    RUDNALDO FERNANDES DIAS DA SILVA

    I guess if I manage to remove everything before numbers in a line AND remove the numbers aswell, it will solve 99,99% of my problem. For every 1000 lines there only one wont have that pattern with the numbers. This one will get highlighted in the dynamic sheet mounted with these data in a Google Sheet. I can fix that black sheep manually easypeasy.

    T 1 Reply Last reply Apr 5, 2023, 7:46 PM Reply Quote 0
    • G
      guy038
      last edited by Apr 5, 2023, 9:22 AM

      Hello, @greg-greg and All,

      Seemingly, you would like to delete from beginning of any line till the string fatura nr. followed with a number and a space character !

      However, in the line Transação via Pix com chave para PRO INT SER DE INF, the string fatura nr. does not occur. In that case, I supposed that you wanted to delete from beginning of line till the word para. Not totally sure about that !

      Thus, use the regex S/R :

      SEARCH (?-is)^.+ fatura nr\. \d+ (.+)|^.+ para (.+)

      REPLACE \1\2

      Best Regards

      guy038

      G 1 Reply Last reply Sep 4, 2023, 10:38 PM Reply Quote 3
      • T
        Terry R @greg greg
        last edited by Terry R Apr 5, 2023, 7:48 PM Apr 5, 2023, 7:46 PM

        @greg-greg said in I need to delete anything before ANY number, AND the number in a line:

        I guess if I manage to remove everything before numbers in a line AND remove the numbers aswell, it will solve 99,99% of my problem.

        As your request was really only to solve the 99.99% of the problem and you didn’t elaborate on the lines without numbers, I figured on solving your request in a different way to @guy038. I also think mine will help with the remaining 0.01% as well.

        1. Mark all lines that have no numbers in them at all, this was what you stated those 0.01% of lines do have in common. The regex to use (in the Mark function) is (?-s)^[^\d]+$ and click “bookmark line” so those lines will be marked with a blue sphere in the left margin. These lines won’t be changed by step #2 so need checking afterwards in step #3.
        2. To remove the portion of each line with a number run this regex on the whole document. Find What: (?-s).+\d+\s, Replace field to be empty. Click Replace all and that will remove all text up to and including the (single group of) numbers and a following space.
        3. In step #1 you marked the lines without numbers. You can now move through those lines using F2 (forwards) and Shift-F2 (backwards) to complete the edits. The “marking” process makes it easier to find the remaining lines to be edited.

        Terry

        G 1 Reply Last reply Sep 4, 2023, 10:39 PM Reply Quote 3
        • G
          greg greg @guy038
          last edited by Sep 4, 2023, 10:38 PM

          @guy038 thanks for the reply, I ended up using the solution from Terry coz I tried it first and it worked just fine hehe

          1 Reply Last reply Reply Quote 1
          • G
            greg greg @Terry R
            last edited by Sep 4, 2023, 10:39 PM

            @Terry-R thanks Terry, I didnt even bothered to do it all, I just searched for (?-s).+\d+\s and replaced with nothing. worked like a charm, no backfiring at all, not even those 0,01% I was expecting to have.

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