Home  >  Article  >  Backend Development  >  字符串中替换指定部分字符的有关问题

字符串中替换指定部分字符的有关问题

WBOY
WBOYOriginal
2016-06-13 12:38:451053browse

字符串中替换指定部分字符的问题
如果字符串中含有连续数字(14位到19位数字),将连续数字中的倒数第三位至倒数第八位,每一位都替换为一个星号(*)。请问,这个怎么实现?谢了先!


例如:
$str1 = 'test123426789127测试';
//只有12位连续数字,不替换,输出 test123426789127测试

$str2 = '中文736484627347493736';
//替换后输出 中文7364846273******36

$str3 = '号码不是73940128493840571X而是83640148493541398X谢谢!';
//替换后输出 号码不是739401284******71X而是836401484******98X谢谢!

PHP
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn