Community
    • Login

    Simple Regex Request -- TIME

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 2.4k Views 1 Watching
    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.
    • AintGotTimeA Offline
      AintGotTime
      last edited by

      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
      • gerdb42G Offline
        gerdb42
        last edited by

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

        1 Reply Last reply Reply Quote 0
        • AintGotTimeA Offline
          AintGotTime
          last edited by

          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
          • gerdb42G Offline
            gerdb42
            last edited by

            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

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors