sky10p / regexh-contributions

Ayuda a traducer la app de regex a más idiomas
9 stars 4 forks source link

[Issue] A regex doesnt match on the app, but does on regex101 #30

Closed Palloxin closed 2 months ago

Palloxin commented 2 months ago

Regex101: immagine

App: Screenshot_20240728-104903_1

regex:

(?<=(?:height|altitude|length|width|wingspan) of (?:almost|over)?|as long as )(?=[aefnost\d])

string: height of one hundred feet

I have no idea why it doesnt match, no errors whatsoever showed.

Every flavour in regex101 gives either "error pattern" or a "match". The app doesnt show any error. Edit: somehow the app doesnt match empty space(position) anymore.

sky10p commented 2 months ago

I have copied the regex you wrote in this issue in regex101 with Java 8 and no match is found

image

Could you try it again and send me the regular expression and text to reproduce it?

Thank you a lot.

Palloxin commented 2 months ago

immagine

I just copied the regex and string from this issue, it works fine. Maybe try again idk. Tried on Firefox and Chrome (Windows 10)

The regex peculiarity is that it doesnt match characters but a specific position: immagine

sky10p commented 2 months ago

I was able to reproduce the issue and found the differences using regex101. In my case, I am discarding all empty strings, while regex101 matches an empty string. Does this really make sense?

Could you explain what the purpose of this regular expression is? I'm analyzing it and can't find any relevant information on matching empty strings. In fact, if I make the changes in my app, you might see one match, but nothing is displayed in the text because it is an empty string.

Palloxin commented 2 months ago

A regex to match a position(empty string) to put the replacement in a specific place. Using looking behind and/or look ahead one can achieve it easily. Example: string: Bobu went to eat regex_1: /(?=Bobu\b)/ replacement_1: DD Final string: DD Bobu went to eat

string: Bobu went to eat regex_1: /(?<=Bobu\b)/ replacement_1: finally Final string: Bobu finally went to eat

More concrete example: Thousands separator(comma)

.replace(/\B(?=(\d\d\d)+(?!\d))/g, ',')

There are also performance reasons. Making mindlessly groups in a regex is not a good idea, performance wise. I just use lookbehind as reference without matching.

sky10p commented 2 months ago

Okey, I'll have in account and fix as soon as possible

Palloxin commented 2 months ago

I recall the app matched this kind of regexes in previous versions. It was just missing the purple like in the image above.

sky10p commented 2 months ago

This will be fixed in version 5.8.2. It may take some time to be deployed as it is currently under review by Google.