Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    remove correlative text from multiple lines

    Help wanted · · · – – – · · ·
    4
    9
    61
    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 Tobar
      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 Olson 1 Reply Last reply Reply Quote 0
      • Mark Olson
        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 Tobar 1 Reply Last reply Reply Quote 1
        • Sergio Tobar
          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 Olson 1 Reply Last reply Reply Quote 0
          • Mark Olson
            Mark Olson @Sergio Tobar last edited by

            @Sergio-Tobar
            Is regular expressions mode on?

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

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

              This is how I am running it

              PeterJones 1 Reply Last reply Reply Quote 0
              • PeterJones
                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 Tobar 1 Reply Last reply Reply Quote 0
                • Sergio Tobar
                  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 Olson 1 Reply Last reply Reply Quote 0
                  • Mark Olson
                    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 Kilborn 1 Reply Last reply Reply Quote 0
                    • Alan Kilborn
                      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
                      Copyright © 2014 NodeBB Forums | Contributors