I'm coding with go 1.8.3 and I want to use regexp package to get "123"
from "1234abcd"
. When I used regexp.Compile("^123(?:4)")
, it came to "1234"
.
Coding in this: https://play.golang.org/p/jB7FmxWz9r
package main
import (
"regexp"
"fmt"
)
func main() {
test, err := regexp.Compile(`^123(?:4)`)
if err != nil {
fmt.Println(err)
return
}
input := "1234|wserw"
fmt.Println(test.FindString(input))
}
came out: 1234
expected: 123