php rtrim结果不正确

php rtrim结果不正确,php,Php,为什么不尝试使用正则表达式匹配字符串 下面的代码将输出您想要的内容: $ret=“更新日期:2014年2月7日创建日期:2014年2月7日到期日期:2015年2月7日>>whois数据库的上次更新:2014年9月30日星期二06:37:52 UTC试试这个 07-feb-2014 Expiration Date: 07-feb-2015 >>> Last update of whois database: Tue, 30 Sep 2014 06:37:52 UTC <&l

为什么不尝试使用正则表达式匹配字符串

下面的代码将输出您想要的内容:

$ret=“更新日期:2014年2月7日创建日期:2014年2月7日到期日期:2015年2月7日>>whois数据库的上次更新:2014年9月30日星期二06:37:52 UTC试试这个

07-feb-2014 Expiration Date: 07-feb-2015 >>> Last update of whois database: Tue, 30 Sep 2014 06:37:52 UTC <<< NOTICE: The expiration date displayed in this record is the date the registrar's sponsorship of the domain name registration in the registry is currently set to expire. This date does not necessarily reflect the expiration date of the domain name registrant's agreement with the sponsoring regis

$ret=“更新日期:2014年2月7日创建日期:2014年2月7日到期日期:2015年2月7日>>whois数据库的最后更新:2014年9月30日星期二06:37:52 UTC在到期日期再次分解$str1:例如,$str2=分解(“到期日期:,$str[1]);echo($str2[0])
rtrim()
适用于单个字符,而不是字符串。双分解或预匹配,由您选择。但在下面的示例中,它工作得很好……根据我的经验,人们会尽可能避免使用正则表达式。正则表达式是复杂的操作,可能需要比您想象的更多的cpu时间。因此,当一个解决方案可以用一种简单的方式实现而无需重新设计时,就使用它。更多信息:你真的不应该把正则表达式当成魔鬼,因为它们是一个非常强大的工具。根据具体情况,它们可能会很昂贵。。在我们的示例“Creation Date:”中,字符串中只有一个匹配项,而且字符串相对较小,因此我认为性能不会受到影响。另一方面,如果您在共享页面中使用“(x+x+)+y”示例这样的表达式,我同意cpu将受到压力。但这只是一个与我的答案无关的用例
07-feb-2014 Expiration Date: 07-feb-2015 >>> Last update of whois database: Tue, 30 Sep 2014 06:37:52 UTC <<< NOTICE: The expiration date displayed in this record is the date the registrar's sponsorship of the domain name registration in the registry is currently set to expire. This date does not necessarily reflect the expiration date of the domain name registrant's agreement with the sponsoring regis
$ret="Updated Date: 07-feb-2014 Creation Date: 07-feb-2014 Expiration Date: 07-feb-2015 >>> Last update of whois database: Tue, 30 Sep 2014 06:37:52 UTC <<< NOTICE: The expiration date displayed in this record is the date the registrar's sponsorship of the domain name registration in the registry is currently set to expire. This date does not necessarily reflect the expiration date of the domain name registrant's agreement with the sponsoring registrar";
       $str=explode("Creation Date:",$ret);
$str2=explode("Expiration Date:",$str[1]); echo ($str2[0]);