remove correlative text from multiple lines
-
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.
-
@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
- The
\d
metacharacter matches any digit. \d{8}
means 8 digits.
is escaped as\.
because that’s also a special metacharacter.
- The
-
@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.
-
@Sergio-Tobar
Is regular expressions mode on? -
This is how I am running it
-
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.
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. -
@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.
-
@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. -
@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.