Closed SaiSasankKhajjayam closed 6 years ago
""
package main
import (
"fmt"
"github.com/dlclark/regexp2"
)
func main() {
re, _ := regexp2.Compile("D.+nt", 0)
fmt.Println(re.MatchString("Deployment")) // true
}
Well, I suggest you to avoid using .*
; consider using .+
first 😃
package main
import ( "fmt" "github.com/dlclark/regexp2" )
func main() { re,_ := regexp2.Compile(
Deployment
, 0) fmt.Println(re.MatchString(D.*
)) // ExpectedOutput: true , ActualOutput: false fmt.Println(re.MatchString(D*
)) // ExpectedOutput: true , ActualOutput: false fmt.Println(re.MatchString(Dep
)) // ExpectedOutput: true , ActualOutput: false fmt.Println(re.MatchString(Deployment
)) // ExpectedOutput: true , ActualOutput: true}