Skip to content

Highlighting a substring in a string #15

@JoyHak

Description

@JoyHak

I really liked the plugin, but I ran into its limitations. I need to highlight some words in specific strings, quotes, after certain commands, and so on.
For example, I want to highlight word in quotes:

"higlight word and some word" 
"and word here" but not w0rd
and not word here   

If I write a regular RegEx word, it will highlight everything in a row. I can't highlight quotes only. If I add all existing styles and delimiters to excluded_styles, I will have to specify a whitelist for each color.

I came up with pure RegEx solution that highlights substrings with a condition:

(?: 
    ["']\K  	# Condition: quotes
)

|  		# Beginning of the loop

(?<=\G)  		# Ensures that the condition is found
[^"']*?  		# Quotes after which the entire regex stops
\K  			# Reset the match start again
\w+  		# Greedy: matches any words/numbers 

 (6)
if condition is not found, alternation (?<=\G) is checked for each character; there is no skipping of unsuitable lines; flags do not work (*SKIP)(*F). Despite the fast speed of work, the number of steps tends to 100,000.

Please add the ability to use nested RegEx: the first one will search for a specific string, the second one will highlight characters/words in it, and so on.
For example:

#fbcf20 = [regex, subregex]

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions