rickysarraf / foxreplace

Automatically exported from code.google.com/p/foxreplace
0 stars 0 forks source link

Text before a regexp is many times ignored #138

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Example:

In the replacing list item "text to replace (a lot of regexp here)", the "text 
to replace" text is ignored and the regexp is read like if the "text to 
replace" didn't exist before it. So every substitution in the list with that 
regexp, only the regexp is considered, no matter what is put before it.

Note: there's no "(word)*" or "(word)?", so I think the problem maybe is the 
addon.

I'm using the most recent Firefox in Windows 7.

Original issue reported on code.google.com by brunolop...@gmail.com on 31 May 2014 at 1:54

GoogleCodeExporter commented 9 years ago
Hi, I don't understand your explanation. Can you give a specific example with 
steps to reproduce, obtained result and expected result?

Original comment by marc.r...@gmail.com on 31 May 2014 at 12:48

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Sorry, I didn't explained it adequately. I'll use the substitution that I'm 
having trouble as an example:
________________________________________________________________________________
_________________________________
Replace:

      The text that FoxReplace bypasses            The regexp that I am referring to (I'll call it "huge regexp")
[    ↓    ↓    ↓    ↓     ↓     ↓      ↓    ] [        ↓        
↓        ↓        ↓        ↓        ↓    .......... 
d((a|á|à)d(o|u)|(e|ê|é|è)(u|l|w|o)|ê|ár*|ar*) 
(m+h*(i+|i+h+)*(e+|é+|è+|ê+|3+|£+)­*h*(r|l)+d+h*(a|á|à|â|ã|4|@)*h*s*|( 
\bm+e+r+d+(\.{2,}|\*+|[^\sáàâãéêíóôõúça-z0-9!?,;/.])+s*|\bm+e+r+(\.{
2,}|\*+|[^\sáàâüãéêíóôõúça-z0-9!?,;/.])+  
                                                   <<<< SIX MORE LINES OF REGEXP >>>>>   
([^\sáàâãéèêíìîóòôõúùûça-z0-9!?])*(a|á|à|â|ã|4|@|\*|\.{2,}
)+([^\sáàâãéèêíìîóòôõúùûça-z0-9])*h*([^\sáàâãéèêíìî�
�òôõúùûça-z0-9])*s*

With:
d$1 problema
________________________________________________________________________________
_________________________________

What I want in this substitution is to replace "d(<<< any of the options 
between the first parenthesis group >>>) (<<< the huge regexp >>>)" with "d<<< 
the option that would be matched, e.g. "á" >>> problema". But, I don't know 
why, FoxReplace just ignores the text preceding the huge regexp, like this:

"que <<< the text that the huge regexp is told to match, e.g. "bosta" (Forgive 
me the word if you understand Portuguese or Spanish, I use FoxReplace as a 
swear filter..)>>>" is replaced by "d problema", but there's a substitution 
that tells what to do when it's preceded by "que", that is replacing with "que 
droga". 

Followed by this substitution, there's 5 more having the huge regexp as suffix, 
but the first one of the list (that is the one I used in the first example) 
almost always matches erroneously, even if the preceding text followed by the 
huge regexp doesn't have a match in the text of a page, harming those 5 others. 

I tried to change the position of the first substitution, but it happens the 
same with any of the five that is left by first. I also tried to move those 
substitutions to a separated list, but no success. 

It was working fine since I started using it, but some time ago it started to 
work randomly, but only with the substitutions with this huge regexp, all the 
others work flawlessly.

Original comment by brunolop...@gmail.com on 2 Jun 2014 at 4:18

GoogleCodeExporter commented 9 years ago
It's hard to tell, but my guess is that you may have an error in the regexp so 
that it matches the empty string. You can try an online regexp tester to test 
for this. I have found this one for example: http://regex101.com/#javascript. 
In the right side at the top it explains the regexp and at the bottom it tells 
you if it matches the test string and how. You should write your whole regexp 
in the regular expression field and leave the test string empty. It should then 
tell you either "no match" or "1 match" to the right of the "regular 
expression" label. You can also try directly with the test string "que bosta" 
or whatever example you have found it fails.

If you don't find any error in the regexp in this way, then I would need the 
full regexp (don't worry about the length) and the example strings where it 
fails.

Original comment by marc.r...@gmail.com on 2 Jun 2014 at 10:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Oh, man...  The error was in my regexp. That was happening because I closed the 
parenthesis before "bosta"'s regexp, so it was interpreting as "d(regexp) 
(word)  OR (another word)", as if the "another word" was a completely separated 
string, excluding the "d(regexp)", and I didn't noticed that error. I copied 
and pasted the same regexp in the other five substitutions, that's why it 
matched strings without the preceding text. Now I moved the closing parenthesis 
before it to the end, now it's working perfectly.

Forgive me the bother and for accusing a false bug in your addon, and thanks 
for the attention.  :)

Original comment by brunolop...@gmail.com on 2 Jun 2014 at 9:24

GoogleCodeExporter commented 9 years ago
Don't worry, these things can happen easily with big regexps ;)

Original comment by marc.r...@gmail.com on 3 Jun 2014 at 7:46