delete PCRE regex
This commit is contained in:
parent
e11af6c567
commit
db684c6ae7
23
unpack.go
23
unpack.go
|
@ -2,21 +2,28 @@ package unpackstring
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/GRbit/go-pcre"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var ErrInvalidString = errors.New("invalid string")
|
||||
|
||||
func Unpack(str string) (string, error) {
|
||||
// Place your code here.
|
||||
|
||||
re, _ := pcre.Compile(`^\d|\d{2,}|\\(?=\D)|(?=\\)`, pcre.UTF8)
|
||||
|
||||
res := re.MatchStringWFlags(str, pcre.UTF8)
|
||||
|
||||
if res == true {
|
||||
return "", ErrInvalidString
|
||||
err := CheckString(str)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func CheckString(str string) error {
|
||||
|
||||
re, _ := regexp.Compile(`^\d|\d{2,}`)
|
||||
|
||||
if re.MatchString(str) == true {
|
||||
return ErrInvalidString
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue