Community
    • Login

    Removing lines help - Confusing ,don’t know how to explain but will try and but need help please

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 44 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.
    • LoisL
      Lois
      last edited by

      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 good

      But 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 good

      So 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

      Terry RT 1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R @Lois
        last edited by

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

        You 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

        LoisL 1 Reply Last reply Reply Quote 1
        • LoisL
          Lois @Terry R
          last edited by

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

          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, 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 good

          Thanks again.

          Terry RT 1 Reply Last reply Reply Quote 0
          • Terry RT
            Terry R @Lois
            last edited by Terry R

            @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 \x20 is 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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors