Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose limiting for * and + in Xeger.xeger() #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

crackhead-koala
Copy link

@crackhead-koala crackhead-koala commented Nov 24, 2024

Hello!

Thank you for this library, it has been very helpful for me in my project. However, I found that the Xeger.xeger() method lacks control over how many characters are generated from a regexp by * and + metacharacters.

This pull request adds the second argument star_plus_limit to this method with the default value of 100. It also removes the constant STAR_PLUS_LIMIT as it is no longer needed.

@crackhead-koala crackhead-koala changed the title Expose limiting for * and + in Xeger.xeger() Expose limiting for * and + in Xeger.xeger() Nov 24, 2024
@crackhead-koala crackhead-koala changed the title Expose limiting for * and + in Xeger.xeger() Expose limiting for * and + in Xeger.xeger() Nov 24, 2024
@bjmc
Copy link
Collaborator

bjmc commented Nov 24, 2024

Thanks for this pull request! Can you explain a little bit more about your use case? Rather than adding another parameter to the xeger() method, why not specify the number of repeats you want in the regular expression?

For example if you wanted to generate up to 500 repetitions of a you could use a{1,500}. Would that work for your situation?

@crackhead-koala
Copy link
Author

I mostly need comparatively shorts strings from regular expressions, at most 10 characters, so setting this limit in every regex is a bit cumbersome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants