Return source if there are no matches in Replace* functions
This commit is contained in:
parent
06785bac1a
commit
4630bc96b4
6
pcre.go
6
pcre.go
@ -378,7 +378,7 @@ func (r *Regexp) ReplaceAll(src, repl []byte) []byte {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if len(matches) == 0 {
|
if len(matches) == 0 {
|
||||||
return nil
|
return src
|
||||||
}
|
}
|
||||||
|
|
||||||
out := make([]byte, len(src))
|
out := make([]byte, len(src))
|
||||||
@ -423,7 +423,7 @@ func (r *Regexp) ReplaceAllFunc(src []byte, repl func([]byte) []byte) []byte {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if len(matches) == 0 {
|
if len(matches) == 0 {
|
||||||
return nil
|
return src
|
||||||
}
|
}
|
||||||
|
|
||||||
out := make([]byte, len(src))
|
out := make([]byte, len(src))
|
||||||
@ -447,7 +447,7 @@ func (r *Regexp) ReplaceAllLiteral(src, repl []byte) []byte {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if len(matches) == 0 {
|
if len(matches) == 0 {
|
||||||
return nil
|
return src
|
||||||
}
|
}
|
||||||
|
|
||||||
out := make([]byte, len(src))
|
out := make([]byte, len(src))
|
||||||
|
Loading…
Reference in New Issue
Block a user