• Login
Community
  • Login

remove correlative text from multiple lines

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 4 Posters 454 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.
  • S
    Sergio Tobar
    last edited by Sergio Tobar Mar 23, 2023, 2:17 PM Mar 23, 2023, 2:12 PM

    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.

    M 1 Reply Last reply Mar 23, 2023, 2:43 PM Reply Quote 0
    • M
      Mark Olson @Sergio Tobar
      last edited by Mark Olson Mar 23, 2023, 2:46 PM Mar 23, 2023, 2:43 PM

      @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.
      S 1 Reply Last reply Mar 23, 2023, 3:16 PM Reply Quote 1
      • S
        Sergio Tobar @Mark Olson
        last edited by Mar 23, 2023, 3:16 PM

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

        M 1 Reply Last reply Mar 23, 2023, 3:17 PM Reply Quote 0
        • M
          Mark Olson @Sergio Tobar
          last edited by Mar 23, 2023, 3:17 PM

          @Sergio-Tobar
          Is regular expressions mode on?

          S 1 Reply Last reply Mar 23, 2023, 3:38 PM Reply Quote 1
          • S
            Sergio Tobar @Mark Olson
            last edited by Mar 23, 2023, 3:38 PM

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

            This is how I am running it

            P 1 Reply Last reply Mar 23, 2023, 3:50 PM Reply Quote 0
            • P
              PeterJones @Sergio Tobar
              last edited by PeterJones Mar 23, 2023, 3:52 PM Mar 23, 2023, 3:50 PM

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

              S 1 Reply Last reply Mar 23, 2023, 4:25 PM Reply Quote 0
              • S
                Sergio Tobar @PeterJones
                last edited by Mar 23, 2023, 4:25 PM

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

                M 1 Reply Last reply Mar 23, 2023, 8:33 PM Reply Quote 0
                • M
                  Mark Olson @Sergio Tobar
                  last edited by Mar 23, 2023, 8:33 PM

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

                  A 1 Reply Last reply Mar 23, 2023, 8:43 PM Reply Quote 0
                  • A
                    Alan Kilborn @Mark Olson
                    last edited by Alan Kilborn Mar 23, 2023, 8:43 PM Mar 23, 2023, 8:43 PM

                    @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
                    4 out of 9
                    • First post
                      4/9
                      Last post
                    The Community of users of the Notepad++ text editor.
                    Powered by NodeBB | Contributors