Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
gstr
提供了丰富的字符串处理。组件内置了90+
个常用的字符串处理方法。
使用方式:
import "github.com/gogf/gf/text/gstr"
接口文档:
https://godoc.org/github.com/gogf/gf/text/gstr
AddSlashes
- 格式: AddSlashes
- 说明: 该方法输入一个带有英文单引号('),双引号("),反斜杠(\)的字符串时,会在其前面加一个反斜杠,强行转义为原样输出
示例:
Code Block language go func Example_AddSlashesExampleAddSlashes() { var str string str = `'aa'"bb"cc\r\n\d\t` rsStr := gstr.AddSlashes(str) fmt.Println(rsStr) // Output: // \'aa\'\"bb\"cc\\r\\n\\d\\t }
Panel | ||
---|---|---|
| ||
|