正文

与化学相关的正则表达式2008-04-20 17:47:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/iamben250/34353.html

分享到:

EINECS号:EINECS = re.compile(r'^\d\d\d-\d\d\d-\d$')
CAS = re.compile(r'^\d*-\d\d-\d$')
分子式:FORMULA = re.compile(r'([A-Z][A-Za-z0-9]+\.?[A-Za-z0-9]+/?[A-Za-z0-9]+)')
CAS号最后验证码的计算方法:

For example, the CAS number of water is 7732-18-5: the checksum is calculated as (8×1 + 1×2 + 2×3 + 3×4 + 7×5 + 7×6) = 105; 105 mod 10 = 5.

Chemical Elements symbols
Expression
^((?-i)A[cglmrstu]|B[aehikr]?|C[adeflmorsu]?|D[bsy]|E[rsu]|F[emf]?|G[ade]|H[efgos]?|I[nk]?|Kr?|L[airu]|M[dgnot]|N[abdeiop]|Os?|P[abdmortu]?|R[abefghnu]|S[bcegimnr]?|T[abcehil]|U(u[bhopqst])?|V|W|Xe|Yb?|Z[nr])$
Description
Chemical elements of the periodic table from 1 to 118.
Matches
Hg
Non-Matches
HE
Author Rating: Not yet rated. Guy Bruneau


 
Title Test Details CAS Number
Expression
\b[1-9]{1}[0-9]{1,5}-\d{2}-\d\b
Description
This is a more robust regex for matching Chemical Abstract Service (CAS) Numbers. This distinguishes between CAS numbers and other identifiers (e.g. EC number).
Matches
50-00-0
Non-Matches
200-001-8
Author Rating: Not yet rated. Jarlath

 
 

阅读(2340) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册