I have a validation for first name and while I'm running the "Start*" it will not pass through the code while I pass the "Start$" then it will pass the string. below is the program:-
package main
import (
"fmt"
"regexp"
)
func main() {
FirstName := "Star*"
var validName = regexp.MustCompile("^[\\p{L}0-9-_&$.,’'\x60()!/ ]*$")
if !validName.MatchString(FirstName) {
fmt.Println("--------------", FirstName)
} else {
fmt.Println(FirstName)
}
FirstName2 := "Star$"
if !validName.MatchString(FirstName2) {
fmt.Println("--------------", FirstName2)
} else {
fmt.Println(FirstName2)
}
}
Delete the use $
inside of the ^[\\p{L}0-9-_&$.,’'\x60()!/ ]*$
so it would be ^[\\p{L}0-9-_&.,’'\x60()!/ ]*$
.