Skip to content

regexp: targetSubString miss match #61465

Closed
@xishengcai

Description

@xishengcai

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_"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions