调整gregx替换方法的参数定义

This commit is contained in:
John
2018-03-08 09:37:19 +08:00
parent d98da91cb2
commit 603dde5f16
2 changed files with 5 additions and 3 deletions

View File

@ -4,7 +4,7 @@
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://gitee.com/johng/gf.
// 正则表达式
// 正则表达式.
package gregx
import (
@ -44,7 +44,7 @@ func MatchAllString(pattern string, src string) ([][]string, error) {
}
// 正则替换(全部替换)
func Replace(pattern string, src, replace []byte) ([]byte, error) {
func Replace(pattern string, replace, src []byte) ([]byte, error) {
reg, err := regexp.Compile(pattern)
if err != nil {
return src, err
@ -53,7 +53,7 @@ func Replace(pattern string, src, replace []byte) ([]byte, error) {
}
// 正则替换(全部替换),字符串
func ReplaceString(pattern, src, replace string) (string, error) {
func ReplaceString(pattern, replace, src string) (string, error) {
r, e := Replace(pattern, []byte(src), []byte(replace))
return string(r), e
}

View File

@ -4,6 +4,8 @@
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://gitee.com/johng/gf.
// 单元测试
package gvalid_test
import (