• Login
Community
  • Login

Adding linebreaks below characters

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
14 Posts 4 Posters 3.8k 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.
  • K
    kracovwolf @Neil Schipper
    last edited by Nov 26, 2021, 12:43 AM

    @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
    
    N 1 Reply Last reply Nov 26, 2021, 1:20 AM Reply Quote 0
    • N
      Neil Schipper @kracovwolf
      last edited by Nov 26, 2021, 1:20 AM

      @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.)

      N 1 Reply Last reply Nov 26, 2021, 2:02 AM Reply Quote 0
      • N
        Neil Schipper @kracovwolf
        last edited by Nov 26, 2021, 1:30 AM

        @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).

        N 1 Reply Last reply Nov 26, 2021, 1:57 AM Reply Quote 0
        • N
          Neil Schipper @Neil Schipper
          last edited by Nov 26, 2021, 1:57 AM

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

          1 Reply Last reply Reply Quote 0
          • N
            Neil Schipper @Neil Schipper
            last edited by Nov 26, 2021, 2:02 AM

            @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
            • G
              guy038
              last edited by guy038 Nov 26, 2021, 9:58 AM Nov 26, 2021, 9:54 AM

              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

              K 1 Reply Last reply Nov 27, 2021, 1:56 AM Reply Quote 0
              • K
                kracovwolf @guy038
                last edited by kracovwolf Nov 27, 2021, 1:57 AM Nov 27, 2021, 1:56 AM

                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
                • G
                  guy038
                  last edited by guy038 Nov 19, 2022, 9:13 PM Nov 27, 2021, 10:44 AM

                  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

                  K 1 Reply Last reply Nov 27, 2021, 11:58 AM Reply Quote 0
                  • K
                    kracovwolf @guy038
                    last edited by Nov 27, 2021, 11:58 AM

                    @guy038 didn’t seem to work

                    alt text

                    1 Reply Last reply Reply Quote 0
                    • G
                      guy038
                      last edited by guy038 Nov 19, 2022, 9:16 PM Nov 27, 2021, 1:10 PM

                      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

                      K 1 Reply Last reply Nov 27, 2021, 6:25 PM Reply Quote 0
                      • K
                        kracovwolf @guy038
                        last edited by Nov 27, 2021, 6:25 PM

                        @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;?

                        A 1 Reply Last reply Nov 27, 2021, 7:18 PM Reply Quote 0
                        • A
                          Alan Kilborn @kracovwolf
                          last edited by Nov 27, 2021, 7:18 PM

                          @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
                          12 out of 14
                          • First post
                            12/14
                            Last post
                          The Community of users of the Notepad++ text editor.
                          Powered by NodeBB | Contributors