Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

博主您好 #15

Closed
Hyebin98 opened this issue Aug 2, 2019 · 15 comments
Closed

博主您好 #15

Hyebin98 opened this issue Aug 2, 2019 · 15 comments

Comments

@Hyebin98
Copy link

Hyebin98 commented Aug 2, 2019

我是在掘金上看到您的文章,您写的真好。是这样的,我这边在做一个车辆VIN的校验,您能帮我写一下吗,谢谢您了

@any86
Copy link
Owner

any86 commented Aug 2, 2019

可以, 但是我第一次听说vin, 你简答说下格式要求, 我也百度下格式

@any86
Copy link
Owner

any86 commented Aug 2, 2019

车架号啊, 是要匹配国际, 还是只要中国即可?

@Hyebin98
Copy link
Author

Hyebin98 commented Aug 2, 2019

应该是国际标准,公司有一些进口车
示例 : 1G1BL52P7TR115520
信息为:1996年、GM(或Suzuki)、产地:美国。
tonylei
May 17 2006, 12:18 PM

@any86
Copy link
Owner

any86 commented Aug 2, 2019

好的, 我写下, 等会 🐳

@Hyebin98
Copy link
Author

Hyebin98 commented Aug 2, 2019

好的,谢谢您了

@any86
Copy link
Owner

any86 commented Aug 2, 2019

https://jingyan.baidu.com/album/5bbb5a1b1dad7413eaa1796e.html?picindex=2

https://baike.baidu.com/item/%E8%BD%A6%E8%BE%86%E8%AF%86%E5%88%AB%E5%8F%B7%E7%A0%81/4338309?fr=aladdin

这个规则有没有精准的说明, 看了几个感觉都不一样呢, 不知道那个对, 而且感觉好像都不对, 我先教你几个关键的知识点, 如果你对他的规则很了解你先自己试试,下面的知识点应该就够了, 我也在仔细看下他的规则:

/^[1-6,9,w,t]$/ // 匹配1到6和9和w和t

/[0-9,A-Z]/ // 匹配数字和大写字母

/^[^1]$/ // 不包含数字1

@Hyebin98
Copy link
Author

Hyebin98 commented Aug 2, 2019

嗯,好的,谢谢您了

@any86
Copy link
Owner

any86 commented Aug 2, 2019

https://blog.csdn.net/shenhonglei1234/article/details/53103161
https://blog.csdn.net/ajianchina/article/details/70227234
这规则我是真没看明白, 我现在给你一个校验了位数/第一位国家编码的正则, 看看够不够你们用:

/^[1-6,9,J,K,L,R,S,T,V,W,Y,Z][0-9,A-Z,a-z]{16}$/.test('1G1BL52P7TR115520') // true

@any86
Copy link
Owner

any86 commented Aug 2, 2019

我想起了手机号的正则, 之前做过调查, 很多人因为怕录入不进去都只是匹配11为数字即当做手机号, 至于手机号是否合法都交给了后端在数据库中验证 ,你这个是不是也一样呢?

https://juejin.im/pin/5d1ea9b6518825026ec4c5c7

@Hyebin98
Copy link
Author

Hyebin98 commented Aug 2, 2019

前后端都要校验,这个vin我也不太懂,应该够用了,真是麻烦您了,谢谢您

@any86
Copy link
Owner

any86 commented Aug 2, 2019

客气客气, 我本来想给你写全面点的, 但是真是没读懂vin的规则.. 🐳

@any86 any86 closed this as completed Aug 2, 2019
@Hyebin98
Copy link
Author

Hyebin98 commented Aug 2, 2019

我昨天看了一天,它这个有不同的说法,没有准确的信息,做起来有难度

@any86
Copy link
Owner

any86 commented Aug 2, 2019

我看好像有个校验位还要做"余数"计算, 那个正则恐怕做不了.
既然后端也验证, 为了保险起见, 我建议用这条:

/^[0-9,A-Z,a-z]{17}$/.test('1G1BL52P7TR115520') // true

万一哪天哪个小国加入了呢...

@Hyebin98
Copy link
Author

Hyebin98 commented Aug 2, 2019

好的,麻烦您了,谢谢

@any86
Copy link
Owner

any86 commented Aug 2, 2019

客气 🐳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants