可以根据汉字拼音的规律用正则检测。
代码只提供大概思路,请自行完善。Local $str = 'www.baidu.com'
Local $str2 = 'woaini.com'
MsgBox(0, $str, _get_Domain_PY_counts($str))
MsgBox(0, $str2, _get_Domain_PY_counts($str2))
Func _get_Domain_PY_counts($sDomain)
If Not StringInStr($sDomain, '.') Then Return SetError(1, '', 0)
Local $aArray
Local $pattern = '((?:[bcdfghjklmnpqrstwxyz]{0,2})[aeiouv]{1,2}(?:[ng]{0,2}))'
If StringInStr($sDomain, 'www') Then
$sDomain = StringRegExpReplace($sDomain, 'www\.(\w+)\..+', '\1')
Else
$sDomain = StringRegExpReplace($sDomain, '\..+', '')
EndIf
$aArray = StringRegExp($sDomain, $pattern, 3)
Return UBound($aArray)
EndFunc
|