Community
    • Login

    remove correlative text from multiple lines

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 4 Posters 409 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.
    • Sergio TobarS
      Sergio Tobar
      last edited by Sergio Tobar

      Re: Help - Remove a line from a specific text but keep a part of the text

      I need to remove this part of several lines,

      2023-03-21 11:55:06 Local7.Debug 172.20.101.21 46259257: GTGTDC_01UNI10_DS4351H:

      But on each line the time and number 4625… changes.

      Two example lines

      2023-03-21 11:55:06 Local7.Debug 172.20.101.21 46259257: GTGTDC_01UNI10_DS4351H: 16336758: Mar 21 11:55:05.842 CST: //9282107/508CC8DF9252/CCAPI/cc_api_event_indication:

      2023-03-21 11:55:06 Local7.Debug 172.20.101.21 46259258: GTGTDC_01UNI10_DS4351H: Event Is Sent To Conferenced SPI(s) Directly.

      Mark OlsonM 1 Reply Last reply Reply Quote 0
      • Mark OlsonM
        Mark Olson @Sergio Tobar
        last edited by Mark Olson

        @Sergio-Tobar
        as written?
        find/replace
        \d{4}-\d\d-\d\d \d\d:\d\d:\d\d Local7\.Debug 172\.20\.101\.21 \d{8}: GTGTDC_01UNI10_DS4351H:
        with nothing (with regular expressions on).

        Explanation

        1. The \d metacharacter matches any digit.
        2. \d{8} means 8 digits
        3. . is escaped as \. because that’s also a special metacharacter.
        Sergio TobarS 1 Reply Last reply Reply Quote 1
        • Sergio TobarS
          Sergio Tobar @Mark Olson
          last edited by

          @Mark-Olson Thanks, I am trying with your example Local7.Debug 172.20.101.21: GTGTDC_01UNI10_DS4351H:

          But for some reason Local7.\Debug can’t find it, I’m trying to change this part but I still can’t get it to work.

          Mark OlsonM 1 Reply Last reply Reply Quote 0
          • Mark OlsonM
            Mark Olson @Sergio Tobar
            last edited by

            @Sergio-Tobar
            Is regular expressions mode on?

            Sergio TobarS 1 Reply Last reply Reply Quote 1
            • Sergio TobarS
              Sergio Tobar @Mark Olson
              last edited by

              @Mark-Olson 1c56e38e-708d-4a36-a8e8-abbcf97ce72a-image.png

              This is how I am running it

              PeterJonesP 1 Reply Last reply Reply Quote 0
              • PeterJonesP
                PeterJones @Sergio Tobar
                last edited by PeterJones

                @Sergio-Tobar ,

                This is how I am running it

                Then you copy/pasted the regex wrong, or you edited it from @Mark-Olson’s version. It is not an invalid regex.

                1072d552-5d83-4216-b393-1a55b53c5ed5-image.png

                Hovering over the ... in the speech bubble in your dialog will even tell you what went wrong in the regex you actually used, and you can then compare what it shows to Mark’s regex, to see what you copy/pasted wrong.

                Sergio TobarS 1 Reply Last reply Reply Quote 0
                • Sergio TobarS
                  Sergio Tobar @PeterJones
                  last edited by

                  @PeterJones @Mark-Olson Perfect worked, the problem was that after the Local7.Debug, in the original file was separated by tab and not by spaces, I separated by tab the regex and it worked fine, thanks for the support.

                  Mark OlsonM 1 Reply Last reply Reply Quote 0
                  • Mark OlsonM
                    Mark Olson @Sergio Tobar
                    last edited by

                    @Sergio-Tobar
                    Glad you figured it out!

                    In the future, if you have some non-whitespace characters separated by arbitrary whitespace (could be spaces, tabs, or newlines), try using \s. It will match all whitespace in a regular expression.

                    Alan KilbornA 1 Reply Last reply Reply Quote 0
                    • Alan KilbornA
                      Alan Kilborn @Mark Olson
                      last edited by Alan Kilborn

                      @Mark-Olson said in remove correlative text from multiple lines:

                      try using \s

                      And note that \h is often better than \s.
                      \s will match end-of-line characters which isn’t always what people expect.

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