Community
    • Login

    Find paragraph of X words containing multiple keywords ?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    22 Posts 4 Posters 5.1k 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.
    • guy038G
      guy038
      last edited by guy038

      Hello, @n_antiyou, @peterjones, @alan-kilborn and All

      @n_antiyou,

      For 6 keywords, you can use that mono-line regex , below, in free-spacing mode, which enables you to place any space within this long regex for a better readability !

      SEARCH / MARK (?xs-i) (?=(\W+ \w+){0,299} \W+ Word_1) (?=(?1){0,299} \W+ Word_2) (?=(?1){0,299} \W+ Word_3) (?=(?1){0,299} \W+ Word_4) (?=(?1){0,299} \W+ Word_5) (?=(?1){0,299} \W+ Word_6) (?1){300}


      Now, you may use the Search > Mark All > Using #th style in order to highlight your keywords with a specific color. Note that, for your 6th keyword, you’ll have to cheat a bit by applying two successive highlightings to the same word ! Just try to mix two styles ;-))

      Best Regards,

      guy038

      P.S. :

      Note that the syntax (\W+ \w+), near the beginning of the regex, defines the group 1 containing the sub-regex \W+\w+, which is re-used, further on, thanks to the simple syntax (?1)

      You’ll find some links to improve yourself in regexes here !

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

        Hi, @n_antiyou and All,

        As I said in my previous post, you may mix some styles, from the 5 styles, available by default, to get other colors, in order to color all your keywords !

        Refer to this post by @Claudia-Frank, who, unfortunately, is no longer active on this forum ! Her contribution was quite important and she provided quantity of excellent Python scripts, too ! Let’s wish her the best and good coding moments ;-))

        https://community.notepad-plus-plus.org/post/27621


        With the help of the NppQCP plugin ( Quick Color Plugin ), I built up a Word image which recapitulates the main style combinations, with significant colors and their RGB coordinates


        3a6919c6-acd7-4a43-80fe-b56305397952-image.png

        Best Regards,

        guy038

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