Community
    • Login

    about selection

    Scheduled Pinned Locked Moved General Discussion
    47 Posts 7 Posters 11.4k 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
      last edited by

      @cisco779k said in about selection:

      I’ve write my post above 5 hours ago. now i want edit, but is not possible

      Correct; basically you have 3 minutes to edit a post. After that, you just create a new post with new information, or revise old information by discussing it in that new post.

      1 Reply Last reply Reply Quote 0
      • cisco779kC
        cisco779k
        last edited by

        ah ok! thanks for the clarification!

        1 Reply Last reply Reply Quote 0
        • astrosofistaA
          astrosofista @cisco779k
          last edited by

          @cisco779k said in about selection:

          anyway: @ astrosofista … your regex work fine and with mark all each field between ### is selected with bookmarks.
          I was interested in this. Thank you for your contribution!

          Great, it’s good to hear that the regex worked fine :)

          Just in case you still need it, here it goes another regex, but this one only selects the hashes ###, so it does the opposite of the one posted yesterday. Click on Find Next to navigate through the file:

          Search: (?s)[^#]+\R\K.*?(?=\R[^#])
          Replace: [leave empty]
          

          Best Regards

          Alan KilbornA 2 Replies Last reply Reply Quote 1
          • Alan KilbornA
            Alan Kilborn @astrosofista
            last edited by Alan Kilborn

            @astrosofista :

            It might be better to express regexes like this (inside of backticks) instead of the way you did it:

            (?s)[^#]+\R\K.*?(?=\R[^#])

            Whenever I see regexes with italics in them here, I think, uhoh, a * got consumed. Note that this is NOT the case for your posting (the regex is fine!), but the wacky italics and color is still “disturbing”.

            Just a suggestion.

            astrosofistaA 1 Reply Last reply Reply Quote 2
            • cisco779kC
              cisco779k
              last edited by

              tanxs to both of them for your reg-ex.
              however i don’t understand why to use reg-ex when on this simple case just enter in search field (or mark) ### …

              astrosofistaA 1 Reply Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn @astrosofista
                last edited by

                @astrosofista said in about selection:

                here it goes another regex, but this one only selects the hashes ###,

                Also, your choice of terminology here (“selects”) probably only confuses the OP. Probably the word “finds” would have been the better way to go. :-)

                1 Reply Last reply Reply Quote 0
                • cisco779kC
                  cisco779k
                  last edited by

                  no confusion. my initial intent (clearly expressed) was a selection of the text from the ### fields.
                  but since this selection is not possible, then i use the mark to make a copy & paste.

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

                    @Alan-Kilborn

                    Now I see —aging eyes here—, thank you, didn’t noticed till now that italics being applied after the * — maybe we need an escape character for avoid that, ha ha.

                    OTOH, I like the message structure or disposition, were the regex is on its own line.

                    Well, will see what can I do.

                    1 Reply Last reply Reply Quote 0
                    • astrosofistaA
                      astrosofista @cisco779k
                      last edited by

                      @cisco779k

                      Three reasons I can think of:

                      1. Error prevention. Regex provides more control than the normal mode, so I can make sure to only match what it is needed —as I haven’t checked the actual file and as I only had seen a sample—, I don’t know if those three hashes are also located in the middle of the file.
                      2. More error prevention. Regex also provides a way to override options that the user inadvertently may have checked. Thus, in the last regex (?s) forces the regex to run a multiline search.
                      3. Personal habit. In my Notepad++ the regex mode is always checked, so my first attempt is to run even simple searches in that mode. I only select the normal mode in order to avoid regex metacharacters intrusion — and get back to regex realm as soon as possible :)
                      Alan KilbornA 2 Replies Last reply Reply Quote 1
                      • Alan KilbornA
                        Alan Kilborn @astrosofista
                        last edited by

                        @astrosofista said in about selection:

                        I only select the normal mode in order to avoid regex metacharacters intrusion — and get back to regex realm as soon as possible

                        Or you could just stay permanently in the regex realm (Search mode = Regular expression) and just lead off any “normal” searches you need to do (because of metacharacters) with a quick \Q – no need to bother with a trailing \E ! :-)

                        You can’t do a Whole word search this way, though, if you ever use that option, because that checkbox is disabled (but you could go to the trouble of adding \b before the \Q and at the other end).

                        astrosofistaA 1 Reply Last reply Reply Quote 2
                        • Alan KilbornA
                          Alan Kilborn @astrosofista
                          last edited by

                          @astrosofista said:

                          …didn’t noticed till now that italics being applied after the * — maybe we need an escape character for avoid that

                          I think maybe we have a misunderstanding. Your regexes in this thread are fine, I was just suggesting

                          this method

                          instead of

                          this method
                          

                          because the second method does some lexing (does it think it is C++ above because it has special highlighting for “this”?) and the first method just leaves everything alone (and thus is probably clearer).

                          astrosofistaA 1 Reply Last reply Reply Quote 3
                          • astrosofistaA
                            astrosofista @Alan Kilborn
                            last edited by astrosofista

                            @Alan-Kilborn said in about selection:

                            I think maybe we have a misunderstanding. Your regexes in this thread are fine, I was just suggesting…

                            Oh, yes. I thought you were suggesting inline regexes —that is, regular expressions in the middle of a paragraph—, which I really found confusing unless the expression is limited to a few characters.

                            So it´s clearer now. I will preserve the message structure while avoiding the multicolored format.

                            1 Reply Last reply Reply Quote 1
                            • astrosofistaA
                              astrosofista @Alan Kilborn
                              last edited by

                              @Alan-Kilborn said in about selection:

                              Or you could just stay permanently in the regex realm…

                              Hmm, it looks very interesting. Will check the documentation, thank you.

                              Concerning the whole word issue, it wouldn’t necessarily be a problem. Because the Matching Brace feature is not available in the Find panel, a tool that I find almost indispensable to handle complex regexes, and both the Search and Replace fields are really short and the font size is too small for my needs, I usually write expressions on the Editor and use hotkeys to import and export them, so adding one or two options may not represent much trouble.

                              But let me first read about it and see if I can adapted it to my ways.

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

                                Hello, @cisco779k, @alan-kilborn, @astrosofista, and All

                                Of course, you certainly know that, in order to insert a code block, you must use, either the syntaxes :

                                ```
                                Code_Text
                                ```

                                or

                                ~~~
                                Code_Text
                                ~~~

                                But, do you know that you can add an indication, after the opening ``` or ~~~, to force a nice visual aspect of a specific language ?

                                Indeed, for example, you may use ```c to display a C code block, ```xml to visualize an XML piece of code and ```py to show a nice python script !

                                And to get only a black foreground text, with a white background, simply use any invalid indication. I usually write the ```z syntax !


                                Here are, below, the different indications that I’ve found out, yet, from the language names and extensions used :

                                    •---------------•--------------•---------------•
                                    |   LANGUAGE    |  MAIN form   |  OTHER forms  |
                                    •---------------•--------------•---------------•
                                    |  bash         |  sh          |  bash         |
                                    |  c            |  c           |  h            |
                                    |  c++          |  cpp         |  hpp          |
                                    |  c#           |  cs          |               |
                                    |  CSS          |  css         |               |
                                    |  DIFF         |  diff        |  patch        |
                                    |  HTML         |  html        |  xhtml        |
                                    |  HTTP         |  http        |  https        |
                                    |  ini file     |  ini         |               |
                                    |  javaScript   |  js / jsx    |  java         |
                                    |  JSON         |  json        |               |
                                    |               |  jsp         |               |
                                    |  Makefile     |  mk / mak    |  makefile     |
                                    |  Objective-C  |  mm          |  objectivec   |
                                    |  Perl         |  pl / pm     |  perl         |
                                    |  php          |  php         |  php3 / php4  |
                                    |  Python       |  py          |  python       |
                                    |  Ruby         |  rb          |  ruby         |
                                    |  SQL          |  sql         |               |
                                    |  XML          |  xml         |  xsl          |
                                    •---------------•--------------•---------------•
                                

                                Note that I’m not sure, exactly, to which languages ( Java, JavaScript (embedded), JavaScript ) refer the indications js and jsp !?

                                Best Regards,

                                guy038

                                astrosofistaA 1 Reply Last reply Reply Quote 4
                                • PeterJonesP
                                  PeterJones
                                  last edited by PeterJones

                                  @guy038 said in about selection:

                                  I usually write the ```z syntax

                                  I always wondered why the z was included, and sometime between last year and now, I had dropped the z to become just ``` alone. Now that I know the purpose of the z (and the other options), I’ll have to start using those.

                                  And if you use the </> button to fomat a block of text, you can still go back above and add in the option; for example, here I added pl to the ``` line after I generated it using </>.

                                  my $default;
                                  open my $fh, '>', 'out.txt' or die "Goodbye, cruel world: $!";
                                  sub hehe { say "haha"; }
                                  BEGIN {
                                      $default = Win32::Mechanize::NotepadPlusPlus::Notepad->_new();
                                  }
                                  

                                  yep, it properly highlights that. cool.

                                  edits: fixed incomplete sentences/thoughts.

                                  1 Reply Last reply Reply Quote 2
                                  • guy038G
                                    guy038
                                    last edited by guy038

                                    Hello, @cisco779k, @alan-kilborn, @astrosofista, @peterjones and All,

                                    Oh…, I’m sorry ! I spoke a little too fast :-(( Peter, I did some tests, again, with your piece of Perl, a Python script, some HTML and C code and…, seemingly, as soon as you click on the </> icon and you paste the different pieces of code, NodeBB seems, each time, to detect correctly the language !?

                                    Indeed, after I added the related indication, and used Ctrl + Z and Ctrl + Y, I did not be able to see any difference in the code !!

                                    So, the table shown, in my previous post, is rather useless. The only interesting case would be if you would show for instance, a Perl script, with the Python syntax !

                                    Could your confirm my tests ?

                                    Cheers,

                                    guy038

                                    1 Reply Last reply Reply Quote 2
                                    • astrosofistaA
                                      astrosofista @guy038
                                      last edited by

                                      @guy038, @cisco779k, @alan-kilborn, @PeterJones, All

                                      Thank you for sharing this interesting and useful info. And also can be mixed!

                                      I played a bit with the available options and selected two alternative ways (js and mk) to the usual one to display regexes:

                                      Search: (?s)[^#]+\R\K.*?(?=\R[^#])
                                      Replace: [leave empty]
                                      
                                      Search: (?s)[^#]+\R\K.*?(?=\R[^#])
                                      Replace: [leave empty]
                                      

                                      Search: (?s)[^#]+\R\K.*?(?=\R[^#])
                                      Replace: [leave empty]

                                      Both alternative displays are not multicolored and don’t mix font styles, so I think are fine. And aiming to create some contrast against text paragraphs, I am currently not sure but probably will use the second one. I hope @alan-kilborn won’t have strong opinions against it, ha ha.

                                      @guy038, let me ask you a question: how do you create those nice tables? Is a free tool? I’m curious.

                                      Best Regards

                                      1 Reply Last reply Reply Quote 2
                                      • PeterJonesP
                                        PeterJones
                                        last edited by PeterJones

                                        @guy038,

                                        Could your confirm my tests ?

                                        auto-identify:

                                        my $default;
                                        open my $fh, '>', 'out.txt' or die "Goodbye, cruel world: $!";
                                        sub hehe { say "haha"; }
                                        BEGIN {
                                            $default = Win32::Mechanize::NotepadPlusPlus::Notepad->_new();
                                        }
                                        

                                        force ```pl

                                        my $default;
                                        open my $fh, '>', 'out.txt' or die "Goodbye, cruel world: $!";
                                        sub hehe { say "haha"; }
                                        BEGIN {
                                            $default = Win32::Mechanize::NotepadPlusPlus::Notepad->_new();
                                        }
                                        

                                        force ```py (purposefully wrong syntax)

                                        my $default;
                                        open my $fh, '>', 'out.txt' or die "Goodbye, cruel world: $!";
                                        sub hehe { say "haha"; }
                                        BEGIN {
                                            $default = Win32::Mechanize::NotepadPlusPlus::Notepad->_new();
                                        }
                                        

                                        force ```z (blank)

                                        my $default;
                                        open my $fh, '>', 'out.txt' or die "Goodbye, cruel world: $!";
                                        sub hehe { say "haha"; }
                                        BEGIN {
                                            $default = Win32::Mechanize::NotepadPlusPlus::Notepad->_new();
                                        }
                                        

                                        indent

                                        my $default;
                                        open my $fh, '>', 'out.txt' or die "Goodbye, cruel world: $!";
                                        sub hehe { say "haha"; }
                                        BEGIN {
                                            $default = Win32::Mechanize::NotepadPlusPlus::Notepad->_new();
                                        }
                                        

                                        summary

                                        yes, it auto-identifies if there’s nothing. But there are times when the text is ambiguous, or truly plaintext, so using the hardcoded filetype will enforce proper syntax highlighting in the forum.

                                        ps

                                        edit: sorry, @astrosofista , for hijacking your thread with this tangent.

                                        astrosofistaA 1 Reply Last reply Reply Quote 1
                                        • Alan KilbornA
                                          Alan Kilborn
                                          last edited by Alan Kilborn

                                          @astrosofista said in about selection:

                                          I hope @alan-kilborn won’t have strong opinions against it, ha ha.

                                          Well… :-)

                                          Do it the way you want, but IMO this would be a more proper way, from your examples:

                                          Search: (?s)[^#]+\R\K.*?(?=\R[^#])
                                          Replace: [leave empty]

                                          It doesn’t muddy what one would copy for the search regex, and since “[leave empty]” isn’t a regex it shouldn’t be specially highlighted.

                                          But, really, it is all pointless. Whatever gets your point across.

                                          Lately my ideal way is this:

                                          Find what box: (?s)[^#]+\R\K.*?(?=\R[^#])
                                          Backward direction checkbox: unticked
                                          Match whole word only checkbox: unticked (and disabled)
                                          Match case checkbox: unticked
                                          Wrap around checkbox: unticked
                                          Search mode radiobutton: Regular expression

                                          …because I have a script that grabs that data right off the Find window, and formats it.

                                          astrosofistaA 1 Reply Last reply Reply Quote 2
                                          • astrosofistaA
                                            astrosofista @PeterJones
                                            last edited by

                                            @PeterJones said in about selection:

                                            edit: sorry, @astrosofista , for hijacking your thread with this tangent.

                                            Nothing to be sorry about, and for sure the info is quite relevant, so I am paying attention.

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