Community
    • Login

    RegEx Help with Backreference I think

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    58 Posts 4 Posters 17.8k 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.
    • Robert Or Janet DiebelR Offline
      Robert Or Janet Diebel @guy038
      last edited by

      This post is deleted!
      1 Reply Last reply Reply Quote 0
      • Robert Or Janet DiebelR Offline
        Robert Or Janet Diebel @guy038
        last edited by

        @guy038 The MACRO reverses line order.
        I can maybe get the changes done with a number of simpler RegEx’s run after the fact, but I would prefer it totally automated if possible.
        Another alternative is to separate the Numbered books and have a separate RegEx to run against them that would allow a number and {space}

        1 Reply Last reply Reply Quote 0
        • guy038G Offline
          guy038
          last edited by guy038

          Hi , @robert-or-janet-diebel,

          Oh… How silly I am ! You’re perfectly right. At first sight, I do not remark this important line, beginning your BookAndVerse macro :

                      <Action type="2" message="0" wParam="42083" lParam="0" sParam="" />
          

          So, instead of using the ^\u[\u\l -]+ part, for the name, we can use, either, the regexes :

          • ^\w[\w'’ -]+

          or

          • ^[[:alnum:]][[:alnum:]'’ -]+ IF no LOW LINE character ( \x{005F} ) occurs in the name

          Within these two regexes, I also added the two apostrophe syntaxes ['’]. If you do not need them, don’t add them in the character class !

          So, given this example, below :

          My very-Best-Novel
          1 Samwele
          5 L'été de tous les dangers
          5 L’été de tous les dangers
          1_ te_ST
          
          • The first regex ^\w[\w'’ -]+ would match the five lines above

          • The second regex ^[[:alnum:]][[:alnum:]'’ -]+ would match the first four lines, only


          Thus, If we take the general case, you must change, in your Step 2, the search regex as below :

          • FIND (?-is)\\v (?=(?s:.+?^(\w[\w'’ -]+ \d+$)))

          Best Regards,

          guy038

          Robert Or Janet DiebelR 4 Replies Last reply Reply Quote 0
          • Robert Or Janet DiebelR Offline
            Robert Or Janet Diebel @guy038
            last edited by Robert Or Janet Diebel

            @guy038 I am so very thankful for your help.
            Sorry I forgot to point out the line order reversal.
            I will give it a try!
            All the best to you and yours.

            1 Reply Last reply Reply Quote 0
            • Robert Or Janet DiebelR Offline
              Robert Or Janet Diebel @guy038
              last edited by

              @guy038 That is working great! I am so thankful!
              Dare I mention my last failing MACRO that should change the {space} after the Book-Chapter:verse to a TAB?
              Same issue, it works if there is no number.
              I will try to figure it out, but if you have any guidance, it would be appreciated.

                      <Macro name="Space2Tab" Ctrl="no" Alt="no" Shift="no" Key="0">
                          <Action type="3" message="1700" wParam="0" lParam="0" sParam="" />
                          <Action type="3" message="1601" wParam="0" lParam="0" sParam="^(\w+\s\d+:\d+)\s(.*)$" />
                          <Action type="3" message="1625" wParam="0" lParam="2" sParam="" />
                          <Action type="3" message="1602" wParam="0" lParam="0" sParam="$1\t$2" />
                          <Action type="3" message="1702" wParam="0" lParam="512" sParam="" />
                          <Action type="3" message="1701" wParam="0" lParam="1609" sParam="" />
                      </Macro>
              
              
              1 Reply Last reply Reply Quote 0
              • Robert Or Janet DiebelR Offline
                Robert Or Janet Diebel @guy038
                last edited by

                @guy038 Got my space-to-tab working.
                Thanx for all your help!

                1 Reply Last reply Reply Quote 0
                • Robert Or Janet DiebelR Offline
                  Robert Or Janet Diebel @guy038
                  last edited by

                  @guy038 Spoke too soon. Got it to change numbered book, then failed on non-numbered.
                  I am still working on it.

                  1 Reply Last reply Reply Quote 0
                  • guy038G Offline
                    guy038
                    last edited by

                    Hello, @robert-or-janet-diebel,

                    I suppose that the following regex S/R should work :

                    • FIND ^([\w ]+\x20\d+:\d+)\x20

                    • REPLACE $1\t

                    Best Regards,

                    guy038

                    Robert Or Janet DiebelR 2 Replies Last reply Reply Quote 0
                    • Robert Or Janet DiebelR Offline
                      Robert Or Janet Diebel @guy038
                      last edited by

                      @guy038 This works on numbered, but not unnumbered.
                      Here is what I tried.

                      ^(\d+?\s?\w+\s\d+:\d+)\s(.*)$
                      

                      It worked on numbered, but not unnumbered
                      I thought the “?” would make it optional.

                      1 Reply Last reply Reply Quote 0
                      • Robert Or Janet DiebelR Offline
                        Robert Or Janet Diebel @guy038
                        last edited by

                        @guy038 Sorry, that does work. I somehow slipped in a space before the RegEx in the MACRO

                        1 Reply Last reply Reply Quote 1

                        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