Find paragraph of X words containing multiple keywords ?
-
Hello, @n_antiyou, @peterjones, @alan-kilborn and All
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 your6th
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 group1
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 !
-
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 aWord
image which recapitulates the main style combinations, with significant colors and theirRGB
coordinates
Best Regards,
guy038