<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>从身份证中获取出生年月日</title>
</head>
<body>
<script type="text/javascript">
var str = "510122199303218990";
var re = /\d{6}([12]\d{3})([01]\d)([0123]\d)\d{4}/;
var id = re.exec(str);
document.write("ID为:"+id[0]+"<br />");
document.write("出生年月日为:"+id[1]+"-"+id[2]+"-"+id[3]);
</script>
</body>
</html>
时间: 2024-10-13 00:36:14