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

Minimum String Length #38

Open
mcrowson opened this issue Mar 26, 2019 · 0 comments
Open

Minimum String Length #38

mcrowson opened this issue Mar 26, 2019 · 0 comments

Comments

@mcrowson
Copy link

mcrowson commented Mar 26, 2019

The limit argument allows me to set a maximum length for the returned string, but i have no way to set the minimum. I attempted to use a forward lookahead in the regex pattern, but it seems like it is ignored.

^(?=.{12,16}$)(9*)$

So that should give me strings with a minimum length of 12 and maximum length of 16 made up of 9s. When i run this it spits out a whole lot of random stuff. If i take away the lookahead, it correctly gives me the 9s

^(9*)$

If lookaheads or lookbehinds are not the right way to set string minimums, what is? If they are the correct way, what is going wrong with exrex?

EDIT: I should note that my desired regex pattern is quite a bit more involved than a bunch of 9s, I am just using it here as a simplified example for setting minimum lengths. My desired pattern for which i wish to set a minimum length is

^(2{0,1}3{0,1}4{0,1}6{0,1}7*8*9*|3{0,1}5{0,1}7*9*)$

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

No branches or pull requests

1 participant