with a as(select'421002198808081818'as pid unionallselect'4210a2198808081818'as pid
)select*from a
where1=1and pid ~'\d{17}(\d|X|x)';
1.2、执行结果
二、‘\d{17}([0-9]|X|x)’
2.1、PostgreSQL例子
with a as(select'421002198808081818'as pid unionallselect'4210a2198808081818'as pid
)select*from a
where1=1-- and pid ~ '\d{17}(\d|X|x)';and pid ~'\d{17}([0-9]|X|x)';
2.2、执行结果
三、‘[0-9]{17}[[0-9]|X|x]’
3.1、PostgreSQL例子
with a as(select'421002198808081818'as pid unionallselect'4210a2198808081818'as pid
)select*from a
where1=1-- and pid ~ '\d{17}(\d|X|x)';-- and pid ~ '\d{17}([0-9]|X|x)';and pid ~'[0-9]{17}[[0-9]|X|x]';