Removing lines help - Confusing ,don’t know how to explain but will try and but need help please
-
So I have a document like the below where the date and name shows then the the participant and then it’s be blank so it then puts the date and name again in the same line. I would to remove all the dates and participant names that are blank after the : but I can’t find how as the dates and times are all different so I can’t do it with a single find. I’ll put an example of what I’d like.
2017-11-21 07:12:40 - Mum: hi
2017-11-21 07:45:37 - Lois: hello there
2017-11-21 16:14:42 - Mum: how are you
2017-11-21 16:15:35 - Lois: Okay thanks
2017-11-21 18:33:07 - Mum: 2017-11-22 05:33:01 - Lois: good.
2017-11-22 05:34:20 - Lois: sounds goodBut I’d like it like this.
2017-11-21 07:12:40 - Mum: hi
2017-11-21 07:45:37 - Lois: hello there
2017-11-21 16:14:42 - Mum: how are you
2017-11-21 16:15:35 - Lois: Okay thanks
2017-11-22 05:33:01 - Lois: good.
2017-11-22 05:34:20 - Lois: sounds goodSo the “ 2017-11-21 18:33:07 - Mum: “ is removed. But the problem is there’s many of these on the document that are blank after the : and have gone into 1 line and they all have different dates and times, so how would I do this? If it’s even possible. I hope I’ve explained this well.
Thank you
-
@Lois said in Removing lines help - Confusing ,don’t know how to explain but will try and but need help please:
If it’s even possible. I hope I’ve explained this well.
As long as the criteria for removal of a partial line is that there is a following year with more text, this might solve your need.
Using the Replace function with a regular expression search mode we have:
Find What:(?-s)^(\d{4}.+? - (.+?: ))(?=\d{4})
Replace With: empty field hereYou can either use the “Replace All” option or if unsure (which might be better on a first run) use the Find Next, then Replace so you can step through the file. This will be slower, but certainly much faster than manually editing the file.
Terry
-
@Terry-R Thank you very much that worked perfectly .
If you don’t mind would you be able to help me on the below too please?
It’s like this …
2017-11-21 07:12:40 - Mum: hi
2017-11-21 07:45:37 - Lois: hello there
2017-11-21 16:14:42 - Mum: how are you
2017-11-21 16:15:35 - Lois: Okay
Thanks
2017-11-22 05:33:01 - Lois: good.
2017-11-22 05:34:20 - Lois: sounds goodAnd I’m basically needing the lines that start their own line with a capital word joined into the upper line to link to that sentence above, an example below.
2017-11-21 07:12:40 - Mum: hi
2017-11-21 07:45:37 - Lois: hello there
2017-11-21 16:14:42 - Mum: how are you
2017-11-21 16:15:35 - Lois: Okay Thanks
2017-11-22 05:33:01 - Lois: good.
2017-11-22 05:34:20 - Lois: sounds goodThanks again.
-
@Lois said in Removing lines help - Confusing ,don’t know how to explain but will try and but need help please:
And I’m basically needing the lines that start their own line with a capital word joined into the upper line to link to that sentence above
Well, I would think you could potentially have any sort of alphabetical characters at the start of a line, not necessarily just a word starting with a capital letter. So this expression looks for any line NOT starting with a number and combines it with the previous line. Again have a run with using the Find Next, then Replace on the first run to check that it solves your need.
Find What:
\R([^\d])
Replace With:\x20${1}
Note that the\x20is the code for a space. Often it’s better to show something rather than the absence of a visible character, but you can just type a single space in that position if you understand it is a position in the expression.Terry
EDIT. Actually in hindsight I think this looks better. It tests for the characters at the start of a line not being a 4 digit one such as the year as the other lines have. If the expression is true (not a year following) then it replaces the carriage return\line feed with a space.
Find What:\R(?!\d{4})
Replace With:\x20