Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Adding linebreaks below characters

    Help wanted · · · – – – · · ·
    4
    14
    278
    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.
    • kracovwolf
      kracovwolf last edited by

      I need to add a linebreak below a line that contains “--------------” hyphens. And I need to know how to make a whole line bold if it contains a specific word or is below the hyphen and linebreak

      Neil Schipper 2 Replies Last reply Reply Quote 0
      • Neil Schipper
        Neil Schipper @kracovwolf last edited by

        @kracovwolf
        Is a correct restatement of your first need the following: Replace
        “hyphens + one newline”
        with
        “hyphens + two newlines”
        ?

        If so, play with Find&Replace function in Extended mode. You will need to worry about finding and replacing each newline as the pair \r\n (ie, CR,LF as made visible when you turn on View -> Show Symbol -> Show End of Line. If you screw this up, other software that processes the file may misbehave.

        As for your second need, npp, as a text editor does not embolden text (even though it allows bolded fonts for styling). Do you mean something like wrapping text with html tags?

        kracovwolf 1 Reply Last reply Reply Quote 0
        • kracovwolf
          kracovwolf @Neil Schipper last edited by

          @neil-schipper Yes sorry I forgot that I was multitasking with a html editor, so yes to the tags.

          For the hyphens, I just need to make

          this:
          text
          ----------
          Specific word
          
          into:
          text
          ----------
          
          Specific word
          
          Neil Schipper 1 Reply Last reply Reply Quote 0
          • Neil Schipper
            Neil Schipper @kracovwolf last edited by

            @kracovwolf OK, I think you have enough to go on now for your first need, no?

            For your second need, it will be using a regex, something along the lines of finding .*?Phrase of interest.*? and replacing with <bold>(1)</bold>. (These are guidelines, not a tested solution. Try to have some fun with it.)

            Neil Schipper 1 Reply Last reply Reply Quote 0
            • Neil Schipper
              Neil Schipper @kracovwolf last edited by

              @kracovwolf said in Adding linebreaks below characters:

              or is below the hyphen and linebreak

              Let us know if you solve your first two needs, then someone will help you with the third…

              ok, roughly it will be finding something like (\-\R\R)(.*) and replacing with (1)<bold>(2)</bold> (and keep . matches newline not checked).

              Neil Schipper 1 Reply Last reply Reply Quote 0
              • Neil Schipper
                Neil Schipper @Neil Schipper last edited by

                @neil-schipper oops: \1<bold>\2</bold> (tested)

                1 Reply Last reply Reply Quote 0
                • Neil Schipper
                  Neil Schipper @Neil Schipper last edited by

                  @neil-schipper said in Adding linebreaks below characters:

                  .?Phrase of interest.? and replacing with <bold>(1)</bold>.

                  That’s also wrong.

                  (.*?Phrase of interest.*?$)
                  <bold>\1</bold>
                  (tested)

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

                    Hello, @kracovwolf, @neil-schipper and All,

                    @kracovwolf, as your number of dashes is not the same between your first post and your raw text, in reverse video, here is my regex solution :

                    • SEARCH ^-{5,}(\R)

                    • REPLACE $0\1

                    which adds an empty line, right after any line of, at least, 5 dashes, beginning a line


                    Regarding your second problem and assuming your statement :

                    And I need to know how to make a whole line bold if it contains a specific word or is below the hyphen and linebreak

                    Here is a regex alternative to the @neil-schipper solution :

                    • SEARCH (?-s).*Place of interest.*|-{5,}\R\R\K.+

                    • REPLACE <bold>$0</bold>


                    Notes :

                    • For these two regex S/R , select the Regular expression search mode and tick the Wrap around option

                    • For the last regex S/R, you must use the Replace All button ( Do not use the Replace button ! )

                    Best Regards,

                    guy038

                    kracovwolf 1 Reply Last reply Reply Quote 0
                    • kracovwolf
                      kracovwolf @guy038 last edited by kracovwolf

                      I’m not sure if it works well. It does add a linebreak, but I forgot that I’m supposed to type words after the linebreak. And the whole line (title) is supposed to have the bold tag.

                      like

                      ------
                      
                      **Title**
                      text here
                      
                      1 Reply Last reply Reply Quote 0
                      • guy038
                        guy038 last edited by guy038

                        Hi, @kracovwolf and All,

                        Ah… yes, regular expressions are the school of precision !

                        So, you mean that you have this kind of INPUT text :

                        -----
                        Title here
                        Text here
                        ...
                        ...
                        

                        and that you expect the OUTPUT text below :

                        -----
                        
                        **Title here**
                        Text here
                        ...
                        ...
                        

                        Right ? If so, use the following regex S/R :

                        SEARCH (?-s)^-{5,}(\R)(.+)

                        REPLACE -----\1\1**\2**

                        Best Regards,

                        guy038

                        kracovwolf 1 Reply Last reply Reply Quote 0
                        • kracovwolf
                          kracovwolf @guy038 last edited by

                          @guy038 didn’t seem to work

                          alt text

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

                            Hi, @kracovwolf and All,

                            Well, You didn’t say that an empty line was already present between the ---- line and the line which must be changed as bold !

                            So, here is the final solution which works in the two cases !

                            With the INPUT text, below :

                            FIRST case :
                            
                            -----
                            Title_1
                            Text here
                            ...
                            ...
                            
                            
                            SECOND case :
                            
                            -----
                            
                            Title_2
                            Other Text here
                            ...
                            ...
                            

                            And using the regex S/R :

                            • SEARCH (?-s)^-{5,}(\R)\R?(.+)

                            • REPLACE -----\1\1**\2**

                            You should get the expected text :

                            FIRST case :
                            
                            -----
                            
                            **Title_1**
                            Text here
                            ...
                            ...
                            
                            
                            SECOND case :
                            
                            -----
                            
                            **Title_2**
                            Other Text here
                            ...
                            ...
                            

                            Cheers,

                            guy038

                            kracovwolf 1 Reply Last reply Reply Quote 0
                            • kracovwolf
                              kracovwolf @guy038 last edited by

                              @guy038 I was wondering why you were using the asterisk, since its not the html tag for bold. so i should swap out the asterisks for <b> or style="font-weight: bold;?

                              Alan Kilborn 1 Reply Last reply Reply Quote 0
                              • Alan Kilborn
                                Alan Kilborn @kracovwolf last edited by

                                @kracovwolf said in Adding linebreaks below characters:

                                so i should swap out the asterisks for <b> or style="font-weight: bold;?

                                You should do that…if that is what you want to obtain.
                                I think you can do a BIT of your own thinking here.

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post
                                Copyright © 2014 NodeBB Forums | Contributors