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/syntax: [\s\S] -> string is unparsable #31807

Closed
hanwen opened this issue May 2, 2019 · 5 comments
Closed

regexp/syntax: [\s\S] -> string is unparsable #31807

hanwen opened this issue May 2, 2019 · 5 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@hanwen
Copy link
Contributor

hanwen commented May 2, 2019

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

go 1.12

Does this issue reproduce with the latest release?

yes.

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

playground

What did you do?

See https://play.golang.org/p/ss5UUhg98GU

What did you expect to see?

I expect regexp to be able to parse back what syntax.Regexp.String() output.

What did you see instead?

"[^]a": error parsing regexp: missing closing ]: [^]a

@hanwen
Copy link
Contributor Author

hanwen commented May 2, 2019

this is causing google/zoekt#82

@mvdan
Copy link
Member

mvdan commented May 3, 2019

Slightly simpler reproducer: https://play.golang.org/p/6prqe3xt2lT

@katiehockman
Copy link
Contributor

/cc @rsc

@katiehockman katiehockman added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 3, 2019
@junyer
Copy link
Contributor

junyer commented May 5, 2019

} else if re.Rune[0] == 0 && re.Rune[len(re.Rune)-1] == unicode.MaxRune {
// Contains 0 and MaxRune. Probably a negated class.
// Print the gaps.
b.WriteRune('^')
for i := 1; i < len(re.Rune)-1; i += 2 {
lo, hi := re.Rune[i]+1, re.Rune[i+1]-1
escape(b, lo, lo == '-')
if lo != hi {
b.WriteRune('-')
escape(b, hi, hi == '-')
}
}
} else {

RE2 had a similar problem, but I fixed it just now in google/re2@cd23be7. ;)

@gopherbot
Copy link

Change https://golang.org/cl/175679 mentions this issue: regexp/syntax: Exclude full range from String negation case

@golang golang locked and limited conversation to collaborators May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants