zeroOrMore() and oneOrMore() do not generat correct results

Open
#36 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
tooling

Research direction

Start by locating zeroOrMore(), oneOrMore(), and maybe() in the Java source, then compare how each method builds its regex fragment. Reproduce the examples from the issue and inspect existing tests, if present. Done means repetition applies to the complete added expression and the generated regex matches the expected grouped form for both methods.

Written by the indexing model from the issue text.

Description

The expression:

regex().add("Java").zeroOrMore().build();

should generate the regex: /(?:Java)*/, just as the expression:

regex().maybe("Java").build();

generates the regex: /(?:Java)?/. However, the first expression actually generates the regex: /Java*/, which is not correct. The oneOrMore() method suffers from the similar problem.

I propose to change both zeroOrMore() and oneOrMore() to accept a string, much as the maybe() method does so it can return the correct result.

Dominant language
Java
Stars
2.6k
Forks
243
Avg merge
26m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from VerbalExpressions/JavaVerbalExpressions

All issues in VerbalExpressions/JavaVerbalExpressions

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.