字符串类型的正则判断

供新手入门和老手参考的教程和相关资料,包括中文帮助

Moderators: tmplinshi, arcticir

arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

字符串类型的正则判断

17 Nov 2016, 19:59

发现我的数个脚本都使用这套正则来判断字符串类型,有必要规范一下.

Code: Select all

Math	= ^(\(*\d+([.,]\d+)*\)*\s*(\+|-|/|\*)\s*)+\d+([.,]\d+)*\)*$
json	= s)^[\[|\{].*[\]|\}]$
ed2k	= im)^[ed2k].*[\|\/]$
Magent	= i)^magnet\:\?xt
url	= (?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))
reg	= i)^(HKCU|HKCR|HKCC|HKU|HKLM|Hkey_)
path	= ^.:\\.*
email	= ^[\w-_.]+@(?:\w+(?::\d+)?\.){1,3}(?:\w+\.?){1,2}$
color	= ^(0x|#)?([a-fA-F0-9]){6}$
clsid	= ^\{[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\}$
ip	= ^((25[0-5]|2[0-4]\d|[01]?\d\d?)($|(?!\.$)\.)){4}$
domain	= ^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$

Return to “教程资料”

Who is online

Users browsing this forum: No registered users and 7 guests