一开始在网上搜索的正则表达式是:

<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>

就可以了。

Logo

前往低代码交流专区

更多推荐