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

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

WBOY
Release: 2016-06-13 12:38:45
Original
1083 people have browsed it

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


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

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

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

PHP
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template