@test-test-0 said,
@PeterJones said in Advanced replace:
^\d{2}:\d{2}:\d{2}\h*
That’s basically what I want, but sometimes it will be slight difference in the characters order in a specific line that I want to delete.
In simple words - sometimes the time (like 09:15:01) will be in the middle of a text line, not just in the beginning.
Here’s an actual example of what I want to do:
Take out those numbers next to the “Line” word, and additionally delete the date and time from each line.
When asking for search-and-replace help, context in regular expressions is everything. If you’re asking for help with regular expressions, you need to be as clear as possible. You said nothing about removing more than just the time.
I tried to use the syntax in FIND you suggested, unfortunately it didn’t work for me.
Because the requirements you listed were different than the requirements you had.
30bc0180-9857-4405-beca-1015a278fbaa-image.png
You still haven’t followed my advice above – presenting before and after data as text (marked with the </> button so it formats as unmodified text in the forum), so that we can copy/paste your text to experiment with – so we’ve still just got your verbal description of the problem as to what you want it to look like when it is done. So there’s a good chance that this second expression I give you won’t work either, because you have not defined your problem to us sufficiently.
I am going to assume you want to convert Line NUMBER: DATE TIME TEXT TO KEEP (where DATE and TIME match the YYYY-MM-DD HH:MM:SS,FFF format that you implied this time around; I am just assuming that NUMBER will be an integer with at least one digit) into Line: TEXT TO KEEP, but I will make the replace expression obvious enough that if you don’t want the Line: left in the final result, you can take it out.
FIND = (?-s)Line\x20\d+:\x20\d{4}-\d{2}-\d{2}\x20\d{2}:\d{2}:\d{2},\d{3}\x20
I used \x20 to indicate the space character, so that there was no question (especially at the end, where I want to delete the final space after the milliseconds as well)
REPLACE = Line:\x20
If you don’t want it prefixed with Line: and a space, just leave the REPLACE empty
Mode = Regular Expression
Here is an example it works with:
Before:
Line 8: 2020-05-12 12:02:03,789 INFO First Line
Line 64: 2020-05-12 12:02:06,789 INFO Second Line
Line 512: 2020-05-12 12:02:09,789 DATA Third Line
Line 8192: 2020-05-12 12:02:13,789 STUFF Fourth Line
Line 16384: 2020-05-12 12:02:16,789 INFO Fifth
Line 32768: 2020-05-12 12:02:16,789 INFO Sixth
Line 65536: 2020-05-12 12:02:16,789 INFO Seventh Heaven
After:
Line: INFO First Line
Line: INFO Second Line
Line: DATA Third Line
Line: STUFF Fourth Line
Line: INFO Fifth
Line: INFO Sixth
Line: INFO Seventh Heaven
If you need changes compared to this, you will have to do a better job of showing that you want to help us help you. I have already explained how to do this in my first post.