fastaddons / AutoHighlight

This repository is for tracking bugs and documentation only
Other
24 stars 3 forks source link

Match multiple lines? #26

Open peace2000 opened 1 year ago

peace2000 commented 1 year ago

Hi, would be it possible to add support for matching multiple lines in RegExp? It doesn't seem to be possible to match for multiple lines currently.

This would probably need an option g in RegExp, but as AH doesn't require / and / to make the rule RegExp, I could not figure out a way how to do multiple line matching.

With g option https://regex101.com/r/l0S8TQ/1 Without g option (the current behavior in AH): https://regex101.com/r/95yoNH/1

Juraj-Masiar commented 1 year ago

Hello, I don't think this is possible, but we can try. I'm using "advanced-mark.js" library that's doing all the searching, so if it supports it, I may be able to add support for that. See his playground here: https://angezid.github.io/advanced-mark.js/playground/ Make sure to switch to "RegExp" tab and then write your regexp, write some testing string below that and hit "Run". I couldn't make it work for multi-line though.

euu2021 commented 8 months ago

Please, is there an alternative way to highlight only if the word is at the beginning of the string? For example, what I would normally do:

Regex: ^aaa

bbb
aaa (this "aaa" gets highlighted)
bbb aaa (this "aaa" doesn't get highlighted)
Juraj-Masiar commented 8 months ago

I think you are looking for word boundary, see also: https://stackoverflow.com/questions/1324676/what-is-a-word-boundary-in-regex

For example I use this one to highlight "S01":

\Ws\d{2}\W
euu2021 commented 8 months ago

I think you are looking for word boundary, see also: https://stackoverflow.com/questions/1324676/what-is-a-word-boundary-in-regex

For example I use this one to highlight "S01":

\Ws\d{2}\W

Thanks. I got it working using non-capturing groups to identify the line break.