本文整理汇总了PHP中QString::IsLengthBeetween方法的典型用法代码示例。如果您正苦于以下问题:PHP QString::IsLengthBeetween方法的具体用法?PHP QString::IsLengthBeetween怎么用?PHP QString::IsLengthBeetween使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QString
的用法示例。
在下文中一共展示了QString::IsLengthBeetween方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetEmailAddresses
/**
* Uses regular expression matching to return an array of valid e-mail addresses
*
* @param string $strAddresses Single string containing e-mail addresses and anything else
* @return string[] An array of e-mail addresses only, or NULL if none
*/
public static function GetEmailAddresses($strAddresses)
{
$strAddressArray = null;
// Define the ATEXT-based DOT-ATOM pattern which defines the LOCAL-PART of
// an ADDRESS-SPEC in RFC 2822
$strDotAtomPattern = "[a-zA-Z0-9\\!\\#\\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\|\\}\\~\\.]+";
// Define the Domain pattern, defined by the allowable domain names in the DNS Root Zone of the internet
// Note that this is stricter than what RFC 2822 allows in DCONTENT, because we assume developers are
// wanting to send email over the internet, and not using it for a completely closed intranet with a
// non-DNS Root Zone compliant domain name infrastructure.
$strDomainPattern = '(?:[a-zA-Z0-9](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?\\.)*[a-zA-Z0-9](?:[a-zA-Z0-9\\-]*[a-zA-Z0-9])?';
// The RegExp Pattern to Use
$strPattern = sprintf('/%s@%s/', $strDotAtomPattern, $strDomainPattern);
// See how many address candidates we have
$strCandidates = explode(',', $strAddresses);
foreach ($strCandidates as $strCandidate) {
if (preg_match($strPattern, $strCandidate, $strCandidateArray) && count($strCandidateArray) == 1) {
$strCandidate = $strCandidateArray[0];
$strParts = explode('@', $strCandidate);
// Validate String Lengths, and add to AddressArray if Valid
if (QString::IsLengthBeetween($strCandidate, 3, 256) && QString::IsLengthBeetween($strParts[0], 1, 64) && QString::IsLengthBeetween($strParts[1], 1, 255)) {
$strAddressArray[] = $strCandidate;
}
}
}
if (count($strAddressArray)) {
return $strAddressArray;
} else {
return null;
}
}