feat: add SubInBetween

This commit is contained in:
dudaodong committed 2024-02-06 17:13:00 +08:00
1 parent 0fc8733915
commit f82f49a4c2
3 files changed
+69 -5

No files matched your search

+1 -5
View File
@@ -5,7 +5,6 @@
package strutil
import (
"reflect"
"regexp"
"strings"
"unicode"
@@ -350,10 +349,7 @@ func RemoveNonPrintable(str string) string {
// StringToBytes converts a string to byte slice without a memory allocation.
func StringToBytes(str string) (b []byte) {
sh := *(*reflect.StringHeader)(unsafe.Pointer(&str))
bh := (*reflect.SliceHeader)(unsafe.Pointer(&b))
bh.Data, bh.Len, bh.Cap = sh.Data, sh.Len, sh.Len
return b
return *(*[]byte)(unsafe.Pointer(&str))
}
// BytesToString converts a byte slice to string without a memory allocation.