• Login
Community
  • Login

Simple Regex Request -- TIME

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 2 Posters 2.0k 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.
  • A
    AintGotTime
    last edited by Jan 24, 2017, 3:17 AM

    Hi

    I have a recurring log that needs to be edited regularly to subtract the time element. I will post an example of the log:

    [18:16:16] John A: Done. That did not take long.
    [18:16:50] Michelle Z: “Any questions so far?”

    What i want:

    John A: Done. That did not take long.
    Michelle Z: “Any questions so far?”

    I attempted to learn the process of creating a Regex but it is all so complicated for me. I did look over several tutorials.
    There is no space before the open bracket on each line and there should not be a space before the name when edited.

    Thank you VERY much for the help!

    1 Reply Last reply Reply Quote 0
    • G
      gerdb42
      last edited by Jan 24, 2017, 8:08 AM

      Use ^\[\d{2}:\d{2}:\d{2}\]\s for searching. Replace with empty string.

      1 Reply Last reply Reply Quote 0
      • A
        AintGotTime
        last edited by Jan 24, 2017, 11:32 AM

        Thank you, thank you, thank you! Not only does it work well but I learned from this and used what I learned already! Your Regex left a space at the beginning of each line because you did not perceive there was an additional space there. I added a \s at the end of it and that got rid of that extra space.

        This was very valuable to me.

        1 Reply Last reply Reply Quote 0
        • G
          gerdb42
          last edited by Jan 26, 2017, 2:38 PM

          Ah, yes, I assumed a fixed single-space Gap. And to match an arbitrary-length sequence of spaces, try \s+ instead of \s\s.

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