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

regexp: does not recognize non-ascii character #21332

Closed
dongweigogo opened this issue Aug 7, 2017 · 3 comments
Closed

regexp: does not recognize non-ascii character #21332

dongweigogo opened this issue Aug 7, 2017 · 3 comments

Comments

@dongweigogo
Copy link

@dongweigogo dongweigogo commented Aug 7, 2017

go 1.8

I need a pattern to only match characters and underlines:
var re=regexp.MustCompile([\w_]*)
however, it also return true for "A_人123" which contains a non-ascii character. Is there any fix for this?

@nussjustin
Copy link
Contributor

@nussjustin nussjustin commented Aug 7, 2017

You can use ^ and $ in your pattern to match the whole input. Example

Please use golang-nuts or stack overflow for these kind of questions in the future.

@dongweigogo
Copy link
Author

@dongweigogo dongweigogo commented Aug 7, 2017

@nussjustin OK, I'll switch to golang-nuts for this

@dsnet
Copy link
Member

@dsnet dsnet commented Aug 7, 2017

Closing this as the issue tracker is intended for bug reports and feature requests. Go nuts is the right place for this. Thanks.

@dsnet dsnet closed this Aug 7, 2017
@mikioh mikioh changed the title regexp does not recognize non-ascii character regexp: does not recognize non-ascii character Aug 7, 2017
@golang golang locked and limited conversation to collaborators Aug 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.