-
Notifications
You must be signed in to change notification settings - Fork 164
Closed
Description
I am using re2j (thx for library!) and use randomly generated strings to test that patterns and logic that I wrote works correctly. I recently found a weird case and I am not sure if it is a bug but feels so because golang regexp
(also re2, right?) behavior is different.
Example
import com.google.re2j.Pattern;
public class Main {
public static void main(String[] args) {
String source = Character.toString(110781);
System.out.println("unquoted: " + Pattern.matches(source, source)); // true
System.out.println("quoted: " + Pattern.matches("\\Q" + source + "\\E", source)); // false
}
}
package main
import (
"fmt"
"regexp"
)
func main() {
source := string([]rune{110781})
matched, _ := regexp.MatchString(source, source)
fmt.Printf("unquoted: %v\n", matched) // true
matched, _ = regexp.MatchString(`\Q` + source + `\E`, source)
fmt.Printf("quoted: %v\n", matched) // true
}
(I hope I did right with that rune to string conversion)
Metadata
Metadata
Assignees
Labels
No labels