当前位置: 首页>>代码示例>>PHP>>正文


PHP QString::IsLengthBeetween方法代码示例

本文整理汇总了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;
     }
 }
开发者ID:harshanurodh,项目名称:qcodo,代码行数:37,代码来源:QEmailServer.class.php


注:本文中的QString::IsLengthBeetween方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。