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: Regex returns true for strings that it should not match #23808

Closed
arunvm123 opened this issue Feb 13, 2018 · 1 comment
Closed

regexp: Regex returns true for strings that it should not match #23808

arunvm123 opened this issue Feb 13, 2018 · 1 comment

Comments

@arunvm123
Copy link

@arunvm123 arunvm123 commented Feb 13, 2018

Please answer these questions before submitting your issue. Thanks!

What did you do?

Tried to construct a regex pattern that matches whitespaces between words, so as to validate names. The pattern should match only letters and whitespaces but seems to return true for other characters as well.

https://play.golang.org/p/3LoX8_haM_6

What did you expect to see?

The program to return false

What did you see instead?

The program returned true

Does this issue reproduce with the latest release (go1.9.4)?

System details

go version go1.9 linux/amd64
GOARCH="amd64"
GOBIN="/home/arunvm/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/arunvm/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build814277393=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOROOT/bin/go version: go version go1.9 linux/amd64
GOROOT/bin/go tool compile -V: compile version go1.9
uname -sr: Linux 4.11.12-100.fc24.x86_64
LSB Version:	:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID:	Fedora
Description:	Fedora release 24 (Twenty Four)
Release:	24
Codename:	TwentyFour
/lib64/libc.so.6: GNU C Library (GNU libc) stable release version 2.23, by Roland McGrath et al.
gdb --version: GNU gdb (GDB) Fedora 7.11.1-86.fc24
@mvdan
Copy link
Member

@mvdan mvdan commented Feb 13, 2018

You're missing the $ at the end, otherwise you get a partial match: https://play.golang.org/p/FJrDA4jlNHE

Always assume that the error is in your code before thinking there is a bug in the standard library. You should also try the forums to ask questions first: https://golang.org/wiki/Questions.

@mvdan mvdan closed this Feb 13, 2018
@mikioh mikioh changed the title Regex returns true for strings that it should not match regexp: Regex returns true for strings that it should not match Feb 21, 2018
@golang golang locked and limited conversation to collaborators Feb 21, 2019
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
3 participants
You can’t perform that action at this time.