I can believe fly.

Tuesday, December 21, 2010

Linux/win下共用正则表达式,获取干净的md5值

linuxwin下执行完md5命令后,各自返回的信息格式有出入,作下记录:

[yusulian@wol-svn-svr0 ysltest]$ md5sum /data/backup/20101217/dop.full20101217.dump

b5952f4f489e9db46115425f01408343  /data/backup/20101217/dop.full20101217.dump

 

E:\WorkDir\yusulian\>D:\soft\too\md5\md5sum.exe E:\WorkDir\temp\svndump\20101217\R0.full20101217.dump

\98b8f16be45b07e64b1dceff19b6a3aa *E:\\WorkDir\\temp\\svndump\\20101217\\R0.full20101217.dump

 

给出共用的正则表达式,获取干净的md5值:

regStr = r"(\\|)(.*)(  | \*)(.*)"

md5Value = re.match(regStr, md5Result).group(2)

return md5Value


--
Elian
 
Configuration Manage Engineer
MSN: smallfish961@hotmail.com
Email: smallfish382+work@gmail.com

No comments: