(regexpPattern RegexpPattern, s string)
| 54 | ) |
| 55 | |
| 56 | func IsMatchString(regexpPattern RegexpPattern, s string) error { |
| 57 | b, _ := regexp.MatchString(string(regexpPattern), s) |
| 58 | if b { |
| 59 | return nil |
| 60 | } |
| 61 | switch regexpPattern { |
| 62 | case EnglishOrNumber_: |
| 63 | return errors.New("只能使用英文字母、数字、下划线,英文字母开头") |
| 64 | case AnyEnglishOrNumber_: |
| 65 | return errors.New("只能使用英文字母、数字、下划线") |
| 66 | case UUIDExp: |
| 67 | return errors.New("只能使用英文字母、数字、横杠、下划线") |
| 68 | default: |
| 69 | return errors.New("非法字符串") |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | // IsMatchVariable 判断字符串是否匹配环境变量标准格式${abc} |
| 74 | func IsMatchVariable(s string) bool { |
nothing calls this directly
no outgoing calls
no test coverage detected