sdar / Multiple-Highlighter

Other
5 stars 2 forks source link

Regexp not working? #11

Open sdar opened 7 years ago

sdar commented 7 years ago

According to dE_logics on AMO regular expressions are not working.

I've tested and can't reproduce the issue on my side so i'll try to explain how regexp works on multiple highlighter cause it may be a little confusing... i was thinking on doing it easier and add more features but the whole web-extensions debacle is a motivation killer.

Anyway lets take this as an example: capture

First you need to check enable and regexp check-boxes. Then you can use any regular expression with the following format: /regexp/flags

example: /\w*use/gim

Ok so the regular expression is composed by \w* any number of word characters next to the use string,

and the flags gim means Global, case Insensitive, Multi line

Here is the result: capture2

PS. Multiple highlighter is full e10s (electrolysis) compatible, and it's not using shims.

shinji-ikari commented 7 years ago

Please, I need some help here. About the Regexp. How can I use it to highlight the 0-9? I tested /[0-9]/number ,but not working. Not like Javascript Regular Expression?

Or: 1011K 4058K 12358K 2011K 301K 9085K 7065K 1034K Highlight the 4058K 12358K 9085K 7065K

sdar commented 7 years ago

/[0-9]/number number is not a flag on javascript, try with /[0-9]/g to highlight all numbers (g is for Global).

You can use pages like regex101 to create and test your regular expressions (select javascript on the side panel) remember that the regular expression has this format /expression/flags.

Or: 1011K 4058K 12358K 2011K 301K 9085K 7065K 1034K Highlight the 4058K 12358K 9085K 7065K

What do you want to highlight? the ones that ends with K and contain a 5?

For that you can use /\w*5\w*K/g that should highlight all the string containing a 5 and ending in K (case sensitive, if you want to match both k or K put an i behind the g flag.)

shinji-ikari commented 7 years ago

I wanna match 4000-99999K, Thanks for the help. I'll check the regex101. 3Q :) By the way, one Regexp each color?Can't put /\w*5\w*K/g /\w*4\w*K/g in one Found it /(\w*2\w*K)|(\w*4\w*K)|(\w*5\w*K)/g

And can make the icon as a switch? First click is highlight, one more click is clean.

sdar commented 7 years ago

can make the icon as a switch

Yeah, was planing to add that feature but mozilla is restricting what addons can do, including the buttons and other features, because of this the extension will not work on firefox versions above 57 (57 included).

It will still work on firefox forks that still support xul and sdk, like waterfox, and I'm looking at the possibilities of porting it to other browsers but the decision has yet to be made, I'll start adding features and fixing bugs after deciding.

I may support firefox again when their new extension system is mature enough, but that's not likely to happen on time for firefox 57 release.

Sorry for the inconveniences.

shinji-ikari commented 7 years ago

Great, good to hear that. It is a good extension. May your kind be your Luck, thanks for the help.