Skip to content

Commit

Permalink
regex
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinZonda committed Apr 11, 2023
1 parent c611a0f commit 4afa6ad
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/regexx/email.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package regexx

import "regexp"

var EmailRegexp = regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
5 changes: 5 additions & 0 deletions pkg/regexx/phone.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package regexx

import "regexp"

var ChPhoneRegexp = regexp.MustCompile("^1(?:3[0-9]|4[5-9]|5[0-9]|6[12456]|7[0-8]|8[0-9]|9[0-9])[0-9]{8}$")
10 changes: 10 additions & 0 deletions pkg/stringx/replace.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package stringx

import "strings"

func ReplaceAll(origin string, newVal string, oldVals ...string) string {
for _, oldVal := range oldVals {
origin = strings.ReplaceAll(origin, oldVal, newVal)
}
return origin
}

0 comments on commit 4afa6ad

Please sign in to comment.