12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package main
- import (
- "regexp"
- "time"
- "unicode"
- )
- func isPlaceAddr(str string) bool {
- if isTelephone(str) {
- return false
- }
- regx,_ := regexp.Compile(specialaddr)
- result:=regx.FindString(str)
- if result !="" {
- return true
- }
- return false
- }
- func isTimestamp(i int64) bool {
- now:=time.Now().Unix()
- if i<now+86400*180 {
- return true
- }
- return false
- }
- func isTelephone(str string) bool {
- reg1:=`^1[3|4|5|6|7|8|9][0-9]\d{8}$`
- regx1,_ := regexp.Compile(reg1)
- arr1:=regx1.FindAllString(str,-1)
- if len(arr1)>0 {
- return true
- }
- reg2:=`^(\d{2,4}-)?\d{7,8}$`
- regx2,_ := regexp.Compile(reg2)
- arr2:=regx2.FindAllString(str,-1)
- if len(arr2)>0 {
- return true
- }
- return false
- }
- func isChinese(str string) bool {
- var count int
- for _, v := range str {
- if unicode.Is(unicode.Han, v) {
- count++
- break
- }
- }
- return count > 0
- }
- func isChineseChar(str string) bool {
- for _, r := range str {
- if unicode.Is(unicode.Scripts["Han"], r) || (regexp.MustCompile("[\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]").MatchString(string(r))) {
- return true
- }
- }
- return false
- }
|