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 (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/GRbit/go-pcre"
|
"regexp"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrInvalidString = errors.New("invalid string")
|
var ErrInvalidString = errors.New("invalid string")
|
||||||
|
|
||||||
func Unpack(str string) (string, error) {
|
func Unpack(str string) (string, error) {
|
||||||
// Place your code here.
|
// Place your code here.
|
||||||
|
err := CheckString(str)
|
||||||
re, _ := pcre.Compile(`^\d|\d{2,}|\\(?=\D)|(?=\\)`, pcre.UTF8)
|
if err != nil {
|
||||||
|
return "", err
|
||||||
res := re.MatchStringWFlags(str, pcre.UTF8)
|
|
||||||
|
|
||||||
if res == true {
|
|
||||||
return "", ErrInvalidString
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "", nil
|
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