- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
132***-6ren">
我有这样的列数据“132154646878”我想从指定位置替换每个的一部分像这样的东西:
substr_replace("132154646878","***",4)
Output => 132***646878
MySQL 中有什么函数吗?
最佳答案
看起来您正在寻找 MySQL 的 INSERT
功能。
INSERT(str, pos, len, newstr)
Returns the string str, with the substring beginning at position pos and len characters long replaced by the string newstr. Returns the original string if pos is not within the length of the string. Replaces the rest of the string from position pos if len is not within the length of the rest of the string. Returns NULL if any argument is NULL.
来源https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_insert
查询
SELECT INSERT("132154646878", 4, LENGTH('***'), "***");
p.s 请记住,当您在 newstr 参数中使用像 utf8 这样的多字节字符集时,您需要使用 CHAR_LENGTH()
而不是关闭 LENGTH()
结果
| INSERT("132154646878", 4, LENGTH('***'), "***") |
| ----------------------------------------------- |
| 132***646878 |
关于mysql - MySQL 中有类似 substr_replace 的东西吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52605993/
substr_replace() 无法按预期工作,因为我处于 while 循环 PHP $c= "2013-01-01 12:00:00"; $d= "2013-01-02 12:00:00"; $d
我有这样的列数据“132154646878”我想从指定位置替换每个的一部分像这样的东西: substr_replace("132154646878","***",4) Output => 132***
我想写入一个文本文件。当我使用 substr_replace() 在 PHP 中,编码发生变化。它不能正确打印希腊字符。如果我不这样做,一切都很好。我该如何解决这个问题? 结果 ε��φδφ δφδ
我是一名优秀的程序员,十分优秀!