• Login
Community
  • Login

Finding a value in one line and prepending it to the next line

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 202 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.
  • M
    MaximillianM
    last edited by Jul 12, 2024, 2:52 AM

    Hi, I would like to do a find in one line and then prepend that value to a line right after that line.
    I’ve found this regex
    Find (my value) [\r\n]+([^\r\n]+)
    Replace \r00:05 min \1

    The challenge is the value I’m trying to find “00:05” is in a time stamp in the form 00:05:05:001

    When I use find and replace with only using as in 05[\r\n]+([^\r\n]+) it works, but returns too many values. When I use the full value I need to find 00:05: 00:05:[\r\n]+([^\r\n]+)it returns no values found. I’m guessing the : with the regex messes up the find.

    Can you see where my error is?

    Thanks

    Below is some more detail if that helps.

    Here is a sample of the text I am searching

    110
    00:04:59.335 --> 00:05:01.725
    So, welcome to this video

    111
    00:05:01.825 --> 00:05:05.525
    If you have any questions

    So the regex would find the 00:05 in the first timestamp and then prepend it to the next line. Note: the first 00:05 could also be in the beginning of the line.

    110
    00:04:59.335 --> 00:05:01.725
    00:05 min So, welcome to this video

    Thanks Again

    C 1 Reply Last reply Jul 12, 2024, 4:43 AM Reply Quote 0
    • C
      Coises @MaximillianM
      last edited by Jul 12, 2024, 4:43 AM

      @MaximillianM said in Finding a value in one line and prepending it to the next line:

      00:05:[\r\n]+([^\r\n]+)

      You want:

      Find what: (00:05:[^\r\n]+[\r\n]+)
      Replace with: \100:05 min

      Though you can’t see it here, there is a space after min.

      M 1 Reply Last reply Jul 12, 2024, 3:30 PM Reply Quote 3
      • M
        MaximillianM @Coises
        last edited by Jul 12, 2024, 3:30 PM

        @Coises said in Finding a value in one line and prepending it to the next line:

        (00:05:[^\r\n]+[\r\n]+)

        Thanks so much!

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