delete PCRE regex

This commit is contained in:
Илья Смышляев 2023-11-01 23:05:25 +03:00
parent e11af6c567
commit db684c6ae7
1 changed files with 15 additions and 8 deletions

View File

@ -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
}