Skip to content

regexp: targetSubString miss match #61465

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

Closed
xishengcai opened this issue Jul 20, 2023 · 0 comments
Closed

regexp: targetSubString miss match #61465

xishengcai opened this issue Jul 20, 2023 · 0 comments

Comments

@xishengcai
Copy link

xishengcai commented Jul 20, 2023

What version of Go are you using (go version)?

$ go version 1.20.1

Does this issue reproduce with the latest release?

not

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

GOHOSTARCH="amd64"
GOHOSTOS="darwin"

What did you do?

func replaceName(name string) {
	reg := regexp.MustCompile(`[^a-zA-Z]gs_`)
	if reg == nil {
		return
	}
	if !reg.Match([]byte(name)) {
		fmt.Println("name: ", name)
		return
	}
}

What did you expect to see?

input case: "gs_abc", "hellgs_"
output: "hellgs_"

What did you see instead?

input case: "gs_abc", "hellgs_"
output: "gs_abc", "hellgs_"

@golang golang locked and limited conversation to collaborators Jul 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants