• Login
Community
  • Login

Wildcard in replace field

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
24 Posts 7 Posters 8.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.
  • D
    daxliniere
    last edited by Jun 9, 2020, 12:01 PM

    A big thank you to everyone who replied to my question offering help. @Alan-Kilborn’s suggestion seems to work perfectly.

    All the best to this great community!
    -Dax.

    1 Reply Last reply Reply Quote 2
    • D
      daxliniere
      last edited by Jul 18, 2020, 4:07 PM

      Hey all!
      I have no idea why, but for some reason, this solution has stopped working…
      Seriosuly, I have no idea what’s going on, but (\d\d:\d\d):(?=\d\d) no longer finds a string of text that looks like 0:10:02 using RegEx.

      Is it possible a recent update to NPP might have broken this or changed syntax??
      I’m so confused.

      Thanks in advance!
      -Dax.

      A 1 Reply Last reply Jul 18, 2020, 4:20 PM Reply Quote 0
      • A
        astrosofista @daxliniere
        last edited by Jul 18, 2020, 4:20 PM

        Hi @daxliniere

        The quoted regex matches strings with two leading numbers, as “00:12:12”.
        In order to match strings with only one leading number, just remove a “\d” from the expression, as (\d:\d\d):(?=\d\d).

        Have fun!

        D 1 Reply Last reply Jul 18, 2020, 4:39 PM Reply Quote 2
        • D
          daxliniere @astrosofista
          last edited by Jul 18, 2020, 4:39 PM

          @astrosofista Thank you so very much!! It works exactly as before.
          I have no clue what could have changed, but this has solved the problem.

          I really appreciate your time on this. I was in the middle of a job and got stuck on this. Was comtemplating manual correction of ~400 lines!

          Have a great weekend. :)
          -Dax.

          1 Reply Last reply Reply Quote 1
          • D
            daxliniere
            last edited by Jul 18, 2020, 4:42 PM

            AHHH!!! I understand it now!

            The data I had been receiving previously had trailing zeros so every line had xx:xx:xx formatting. It seems whoever was typing this started dropping the trailing zeros.
            Is there a more robust form of (\d:\d\d):(?=\d\d) needed?

            P 1 Reply Last reply Jul 18, 2020, 4:48 PM Reply Quote 1
            • P
              PeterJones @daxliniere
              last edited by Jul 18, 2020, 4:48 PM

              @daxliniere ,

              You say “trailing”, but the regex shown (as modified by @astrosofista) has removed the requirement for leading zeros. To make it match both, I’d do (\d{1,2}:\d\d):(?=\d\d), which will match whether there is one digit or two.

              But if you give an example of “with” or “without” “trailing zeros”, we can be more confident of what you’re really asking for.

              T 1 Reply Last reply Jul 19, 2020, 8:00 AM Reply Quote 2
              • T
                Thomas 2020 @PeterJones
                last edited by Jul 19, 2020, 8:00 AM

                @PeterJones
                instead:
                (\d{1,2}:\d\d):(?=\d\d)

                maybe that’s better?
                (:\d{1,2}):

                the shorter the pattern, the better

                P 1 Reply Last reply Jul 19, 2020, 2:20 PM Reply Quote 0
                • P
                  PeterJones @Thomas 2020
                  last edited by Jul 19, 2020, 2:20 PM

                  @Pan-Jan ,

                  Your regex does not provide all the same groups (and thus features) of the regex developed through this thread, and thus likely misses some of the functionality needed

                  1 Reply Last reply Reply Quote 0
                  • T
                    Thomas 2020
                    last edited by Thomas 2020 Jul 19, 2020, 2:36 PM Jul 19, 2020, 2:34 PM

                    @PeterJones said in Wildcard in replace field:

                    and thus likely misses some of the functionality needed

                    show on the example in this thread that it doesn’t work

                    (\d{1,2}:\d\d):(?=\d\d)
                    but this one has disadvantages, and he will also mark it here
                    126:23:45
                    126:23:450
                    12:23:45:67

                    it will be correct

                    (^| )(\d{1,2}:\d\d):(?=\d\d( |$))

                    1 Reply Last reply Reply Quote 0
                    • T
                      Thomas 2020
                      last edited by Thomas 2020 Jul 19, 2020, 4:16 PM Jul 19, 2020, 4:14 PM

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • T
                        Thomas 2020
                        last edited by Thomas 2020 Jul 19, 2020, 4:26 PM Jul 19, 2020, 4:24 PM

                        (^| )(\d{1,2}:\d\d):(?=\d\d([ ,'!\.\?"”\)]|$))

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