Community
    • Login

    Creating Line Break when there are multiple spaces on tagged line.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    17 Posts 3 Posters 1.2k 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.
    • Alan KilbornA
      Alan Kilborn @Ashley Hoogenboom
      last edited by

      @ashley-hoogenboom said in Creating Line Break when there are multiple spaces on tagged line.:

      On any line that starts with C2: to create a new line when there is 3 spaces

      I don’t see any C2 lines with 3 spaces.
      You aren’t following the guidelines for posting for this sort of help.
      See HERE for that.

      Ashley HoogenboomA 1 Reply Last reply Reply Quote 0
      • Lycan ThropeL
        Lycan Thrope @Ashley Hoogenboom
        last edited by

        @ashley-hoogenboom ,

        Take this with a grain of salt, as this is my first attempt at helping with this stuff that’s not mine. :)

        S/R:
        Find what: ^(\[C2:)(\w+)(.*)
        Replace with: $1$2\n$1$3

        This worked for me with your example text, so take it for what it’s worth.

        Lee

        1 Reply Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @Ashley Hoogenboom
          last edited by

          @ashley-hoogenboom said in Creating Line Break when there are multiple spaces on tagged line.:

          On any line that starts with C2: to create a new line when there is 3 spaces

          Ok, a few ways to interpret that… :-)
          You meant (roughly) word-space1-word-space2-word-space3-word. 3 spaces. Got it.

          1 Reply Last reply Reply Quote 0
          • Ashley HoogenboomA
            Ashley Hoogenboom @Alan Kilborn
            last edited by

            @alan-kilborn

            Thank you for guiding me to the template…that makes it a lot easier. I will be sure to use that moving forward.

            Fellow Notepad++ Users,

            Could you please help me the the following search-and-replace problem I am having?

            On any line that starts with C2: to create a new line when there is 3 spaces. And also create the C2: tag on the new line.

            Here is the data I currently have (“before” data):

            [Y:prn]
            [C0:MNB WT REPORTS]
            [D:8/7/2019 11:07:29 PM]
            [C9:5]
            [C1:SynergyExport/440919]
            [C2:WT2400P   Wire Transfer Notices]
            [C10:661703]
            [Y:prn]
            [C0:MNB AA REPORTS]
            [D:8/7/2019 11:07:29 PM]
            [C9:5]
            [C1:SynergyExport/440920]
            [C2:BSFRG00294   User Profile Changes]
            [C10:661704]
            

            Here is how I would like that data to look (“after” data):

            [Y:prn]
            [C0:MNB WT REPORTS]
            [D:8/7/2019 11:07:29 PM]
            [C9:5]
            [C1:SynergyExport/440919]
            [C2:WT2400P
            [C2:Wire Transfer Notices]
            [C10:661703]
            [Y:prn]
            [C0:MNB AA REPORTS]
            [D:8/7/2019 11:07:29 PM]
            [C9:5]
            [C1:SynergyExport/440920]
            [C2:BSFRG00294
            [C2:User Profile Changes]
            [C10:661704]
            

            I am not really sure where to begin, I’m a beginner. But really want to learn!

            Find What = ^([C2:)
            Replace With =
            Search Mode = REGULAR EXPRESSION or NORMAL or EXTENDED
            Dot Matches Newline = CHECKED or NOT CHECKED
            HERE IS WHY YOU THOUGHT YOUR EXPRESSION WOULD WORK

            Unfortunately, this did not produce the output I desired, and I’m not sure why. Could you please help me understand what went wrong and help me find the solution?

            Thank you.

            Alan KilbornA Lycan ThropeL 2 Replies Last reply Reply Quote 1
            • Alan KilbornA
              Alan Kilborn @Ashley Hoogenboom
              last edited by Alan Kilborn

              @ashley-hoogenboom said in Creating Line Break when there are multiple spaces on tagged line.:

              [C2:WT2400P   Wire Transfer Notices]
              

              Ah ha! Another definition of “3 spaces”! :-)

              @ashley-hoogenboom said in Creating Line Break when there are multiple spaces on tagged line.:

              But really want to learn!

              We like people like that! :-)

              Ashley HoogenboomA 1 Reply Last reply Reply Quote 1
              • Ashley HoogenboomA
                Ashley Hoogenboom @Alan Kilborn
                last edited by

                @alan-kilborn said in Creating Line Break when there are multiple spaces on tagged line.:

                Ah ha! Another definition of “3 spaces”! :-)

                Yes, sorry the first time when I copied it over it didn’t keep the additional spacing.

                Alan KilbornA Lycan ThropeL 2 Replies Last reply Reply Quote 0
                • Alan KilbornA
                  Alan Kilborn @Ashley Hoogenboom
                  last edited by Alan Kilborn

                  @ashley-hoogenboom

                  Try:

                  find: (?-s)^((\\[C2:)\w+)\x20{3}(.+)\\](\R)
                  repl: ${1}]${4}${2}${3}]${4}
                  search mode: regular expression

                  Ashley HoogenboomA 1 Reply Last reply Reply Quote 3
                  • Lycan ThropeL
                    Lycan Thrope @Ashley Hoogenboom
                    last edited by

                    @ashley-hoogenboom ,

                    Then you need to better prepare your example texts so someone doesn’t ignore you in exhaustion. Like you, I didn’t know crap about this Regex stuff until I needed to learn here with these good people’s help, but I always gave them exactly what I was using, what I needed and how it should look. This of course, is after I had beat my head silly trying to learn this on my own, so I at least had an inkling of what they were telling me in response…even if I didn’t understand what it was. I suggest you do the same. Learn what you can, then ask questions as you go, but changing the goal posts of what you want from the same piece of text is on you.

                    Honestly, I’ve been following this forum in the background and now I understand the frustration these folks have gotten to, trying to help people that don’t have an inkling of what it is they really want and expect people to read their intentions, rather than their needs.

                    Lee

                    Alan KilbornA 1 Reply Last reply Reply Quote 2
                    • Lycan ThropeL
                      Lycan Thrope @Ashley Hoogenboom
                      last edited by

                      @ashley-hoogenboom
                      C2_S_RScreenshot.PNG

                      1 Reply Last reply Reply Quote 0
                      • Alan KilbornA
                        Alan Kilborn @Lycan Thrope
                        last edited by

                        @lycan-thrope said in Creating Line Break when there are multiple spaces on tagged line.:

                        Then you need to better prepare your example texts

                        A bit harsh. You don’t know what you aren’t doing right until someone tells you, most times…

                        The OP seemed very agreeable to read the info I pointed to, and rework the question/data to conform.

                        Lycan ThropeL 1 Reply Last reply Reply Quote 0
                        • Lycan ThropeL
                          Lycan Thrope @Alan Kilborn
                          last edited by Lycan Thrope

                          @alan-kilborn ,

                          Perhaps, but I was the recipient of like until I got the system right, too. Mostly my problems stemmed from trying to describe the problem without knowing what the forum’s formatting norms were. It was my bad…and I was called on carpet about it, too, appropriately. :)

                          Interestingly, my solution should have worked for him, anyway, spaces or not.::shrug::

                          Lee

                          Ashley HoogenboomA 1 Reply Last reply Reply Quote 0
                          • Ashley HoogenboomA
                            Ashley Hoogenboom @Alan Kilborn
                            last edited by

                            @alan-kilborn said in Creating Line Break when there are multiple spaces on tagged line.:

                            (?-s)^(([C2:)\w+)\x20{3}(.+)](\R)

                            Thank you! That worked! If you have time can you explain that to me. If not I will be looking it up to make sense of it all.

                            Alan KilbornA 1 Reply Last reply Reply Quote 1
                            • Alan KilbornA
                              Alan Kilborn @Ashley Hoogenboom
                              last edited by

                              @ashley-hoogenboom said in Creating Line Break when there are multiple spaces on tagged line.:

                              If you have time can you explain that to me

                              (?-s)^(([C2:)\w+)\x20{3}(.+)](\R)

                              (?-s)^((\[C2:)\w+)\x20{3}(.+)\](\R)
                              
                              • Use these options for the whole regular expression (?-s)
                                • (hyphen inverts the meaning of the letters that follow) -
                                • Dot doesn’t match line breaks s
                              • Assert position at the beginning of a line (at beginning of the string or after a line break character) (carriage return and line feed, form feed, next line, line separator, paragraph separator) ^
                              • Match the regex below and capture its match into backreference number 1 ((\[C2:)\w+)
                                • Match the regex below and capture its match into backreference number 2 (\[C2:)
                                  • [Match the character “” literally \[
                                  • Match the character string “C2:” literally (case sensitive) C2:
                                • Match a single character that is a “word character” (Unicode; any letter or ideograph, digit, letter number, underscore) \w+
                                  • Between one and unlimited times, as many times as possible, giving back as needed (greedy) +
                              • Match the character “ ” which occupies position 0x20 (32 decimal) in the character set \x20{3}
                                • Exactly 3 times {3}
                              • Match the regex below and capture its match into backreference number 3 (.+)
                                • Match any single character that is NOT a line break character (line feed, carriage return, form feed, next line, line separator, paragraph separator) .+
                                  • Between one and unlimited times, as many times as possible, giving back as needed (greedy) +
                              • [Match the character “]” literally]3 \]
                              • Match the regex below and capture its match into backreference number 4 (\R)
                                • Match a line break (carriage return and line feed pair, sole line feed, sole carriage return, vertical tab, form feed, next line, line separator, or paragraph separator) \R

                              ${1}]${4}${2}${3}]${4}

                              • Insert the text that was last matched by capturing group number 1 ${1}
                              • [Insert the character “]” literally]4 ]
                              • Insert the text that was last matched by capturing group number 4 ${4}
                              • Insert the text that was last matched by capturing group number 2 ${2}
                              • Insert the text that was last matched by capturing group number 3 ${3}
                              • [Insert the character “]” literally]4 ]
                              • Insert the text that was last matched by capturing group number 4 ${4}

                              Created with RegexBuddy

                              Ashley HoogenboomA 1 Reply Last reply Reply Quote 3
                              • Ashley HoogenboomA
                                Ashley Hoogenboom @Lycan Thrope
                                last edited by

                                @lycan-thrope Thank you for your willingness to try and help me as well. I am new to this site as of last night, and I will be sure to follow the rules and make sure I am giving the correct sample. :-)

                                Lycan ThropeL 1 Reply Last reply Reply Quote 1
                                • Ashley HoogenboomA
                                  Ashley Hoogenboom @Alan Kilborn
                                  last edited by

                                  @alan-kilborn Amazing! Thank you so much

                                  1 Reply Last reply Reply Quote 1
                                  • Lycan ThropeL
                                    Lycan Thrope @Ashley Hoogenboom
                                    last edited by

                                    @ashley-hoogenboom ,
                                    All they can ask. I feel for these guys that do this day in and day out. You were my first attempt, and I was kind of angry when you changed the goal. :) That said, welcome to the NPP forum, community and ask away. The only stupid question, is the one not asked. :)

                                    Lee

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