vue+element 实现身份证号码中间几位用星号显示.
一开始在网上搜索的正则表达式是:<el-table-column prop="ucnum" label="证件编号" min-width="18%" align="center"><template slot-scope="scope">{{scope.row.ucnum? scope.row.ucnum.replace(/^(\d{4})\d+(\d{4})$/,...
·
一开始在网上搜索的正则表达式是:
<el-table-column prop="ucnum" label="证件编号" min-width="18%" align="center">
<template slot-scope="scope">{{scope.row.ucnum? scope.row.ucnum.replace(/^(\d{4})\d+(\d{4})$/,"$1****$2"):""}}</template>
</el-table-column>
但是很快发现身份证号码尾部为X的话就失效了
换成这个:
<el-table-column prop="ucnum" label="证件编号" min-width="18%" align="center">
<template slot-scope="scope">{{scope.row.ucnum? scope.row.ucnum.replace(/^(.{6})(?:\w+)(.{4})$/, "\$1********\$2"):""}}</template>
</el-table-column>
就可以了。
更多推荐
所有评论(0)