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

Accept '.' in regexp #12

Closed
Preetam opened this issue Oct 12, 2014 · 3 comments · Fixed by #13
Closed

Accept '.' in regexp #12

Preetam opened this issue Oct 12, 2014 · 3 comments · Fixed by #13

Comments

@Preetam
Copy link
Contributor

Preetam commented Oct 12, 2014

expr = strings.Replace(expr, ">", ">[\\d\\w\\-\\_]+)", -1)

expr = strings.Replace(expr, ">", ">[\\d\\w\\-\\_]+)", -1)

I'm doing something like GET /<host> where host is an IP address. @xaprb, do you think it's a good idea to add periods to the regexp?

@JnBrymn
Copy link
Contributor

JnBrymn commented Oct 12, 2014

Why would periods be a bad idea?

Somewhat related, I'd stick the regex in single quotes so that you don't have to double escape everything. Also, you can simplify that regex bit. This should be equivalent.>[\w-]+because\dis included in\wand you don't have to escape-. If you want the dot, you don't have to escape it within square brackets because it only means "match all" outside of brackets. So this: >[\w-_.]+would match>1-under_score.10but it correctly would not match>@at_is_bad`.

@Preetam
Copy link
Contributor Author

Preetam commented Oct 12, 2014

I agree. I borrowed that code and didn't change it because I thought the original author wrote it that way for certain reasons. :)

@xaprb
Copy link

xaprb commented Oct 12, 2014

I think the original author wasn't fluent in regexp :)

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 a pull request may close this issue.

3 participants