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

It don't know about character class #15

Open
deemytch opened this issue Nov 10, 2014 · 3 comments
Open

It don't know about character class #15

deemytch opened this issue Nov 10, 2014 · 3 comments

Comments

@deemytch
Copy link

/^[0-9a-f]{24}$/.gen
produces "^[0-9a-f]]]]]]]]]]]]]]]]]]]]]]]]$"

must be a long hex number

@bbrotherton
Copy link

I believe you may have meant:

/^[0-9a-f]{,24}$/.gen

However, I am not sure what omitting the comma SHOULD do.

@deemytch
Copy link
Author

No, I mean exactly that. In regexpes:
{number} means exactly that number of repetitions
{,number} means "no more"
{number,} means "more than"
{number,number} means "between"

that's expression /[0-9a-fA-F]{32}/ correspond to the output of SecureRandom.hex(32)

example:

$ irb
> "bbaaaaa" =~ /a{5}/
=> 2
irb(main):002:0> "aaaaa" =~ /a{6}/
=> nil

@bbrotherton
Copy link

Sorry. You're right. It's been a while since I've worked with regexes extensively. Even then I probably would have used {24,24}.

It is a bit odd that there are 24 closing square brackets (']'). Almost like it too all the preceding characters as literals...

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

2 participants