sky10p / regexh-contributions

Ayuda a traducer la app de regex a más idiomas
8 stars 3 forks source link

Allow quantifiers in non-capturing groups #8

Closed Palloxin closed 8 months ago

Palloxin commented 8 months ago
/(?<=\d+)Bob/

string: 6Bob It doesnt match in the app.

The quantifiers not usable in them is really a big hole in the app.

sky10p commented 8 months ago

I apologize for the inconvenience caused by the malfunction of the quantifier. I was unaware when the problem started, but I will try to work on this as soon as possible to find a solution.

Thank you for your feedback.

Palloxin commented 8 months ago

I also found that this doesnt work regex: /(bbb)(?<=aaa\1)/ string: aaabbb

sky10p commented 8 months ago

I was looking into these regular expressions, it seems a limitation in regex in Java:

java.util.regex.PatternSyntaxException: Look-behind pattern matches must have a bounded maximum length near index 8 (?<=\d+)Bob

If you use \d{1} inside the look-behind expression it works, but I am trying to find a solution. The error is happening only in the Android environment, I have added a test and it works correctly but when I execute in Android, it seems a limitation.

Palloxin commented 8 months ago

On the website regex101.com there is the same problem. The lookbehind with quantifiers doesnt works but if i switch to ECMAScript (Javascript) the quantifiers into look behind are accepted just fine. IMG_20240113_151031

sky10p commented 8 months ago

Currently, RegexH is fully integrated with Java regex, which presents these limitations. Consequently, finding straightforward solutions appears challenging.

I am contemplating two potential approaches, although both require substantial refactoring:

  1. Implement a feature in RegexH that detects Java regex pattern errors and prompts the user to modify their regular expression accordingly.
  2. Revise the entire codebase to support a stable dependency that can handle regex in Android, such as ECMA Javascript. However, a reliable option has not yet been identified.

I will persist in exploring these solutions, but please be aware that hits process is expected to be time-consuming.

sky10p commented 8 months ago

For now, the solution will be shown in the explain section java errors, since this error is solved by limiting the range, for example instead of (<?+d), you can use (<?\d{1,8}), it will be not considered a specific bug of my app, but I have aggregated the errors in the explain to make it more clear to the user.

It will be added in version 5.0.2, it should be ready for the next week.

Palloxin commented 8 months ago

What about (a)(?<=\1)?