我目前正在一个PHP模板(使用这)上输出一些身份信息,该模板通过这个变量$whois_answer返回大量文本
相关日期:登记日期:19-8月-2015年到期日期:19-8月-2025年最后更新日期:21-9月-2015年登记状态:登记截止日期。名称服务器: xxx.mainnameserver.com xxx.mainnameserver.com WHOIS查找在09:34:40 10-2017年11月--这一WHOIS信息是免费提供的诺米内英国,中央注册中心.uk域名。这一信息和.uk WHOIS是:版权诺米内英国1996-2017年.您不得访问.uk WHOIS或使用它中的任何数据,除非在http://www.nominet.uk/whoisterms完全可用的使用条款允许的情况下,这包括以下方面的限制:(A)将数据用于广告或其重新包装、重新编译、重新分配或重用(B)遮挡、删除或隐藏本通知的任何或全部,以及(C)超过查询速率或数量限制。这些数据是在“如实”的基础上提供的,可能落后于登记册。访问可能在任何时候被撤回或限制。域注册
我不想修改原始代码,只需要修改最终输出(因为我以后可能会使用其他功能)。
我只想抓住域名的到期日期,我怎么才能瞄准它,把所有的东西都去掉呢?请注意,域是动态的,因此日期可以是任何内容,但总是以该格式。
发布于 2017-11-10 09:58:45
使用preg_match:
$str ="Relevant dates: Registered on: 19-Aug-2015 Expiry date: 19-Aug-2025 Last updated: 21-Sep-2015 Registration status: Registered until expiry date. Name servers: xxx.mainnameserver.com xxx.mainnameserver.com WHOIS lookup made at 09:34:40 10-Nov-2017 -- This WHOIS information is provided for free by Nominet UK the central registry for .uk domain names. This information and the .uk WHOIS are: Copyright Nominet UK 1996 - 2017. You may not access the .uk WHOIS or use any data from it except as permitted by the terms of use available in full at http://www.nominet.uk/whoisterms, which includes restrictions on: (A) use of the data for advertising, or its repackaging, recompilation, redistribution or reuse (B) obscuring, removing or hiding any or all of this notice and (C) exceeding query rate or volume limits. The data is provided on an 'as-is' basis and may lag behind the register. Access may be withdrawn or restricted at any time. Domain is registered";
Preg_match("/Expiry date:\s([a-zA-Z0-9-]+)/", $str, $match);
Echo $match[1];这将匹配“到期日期”,然后捕获:a-Z、0-9和-,这意味着它将在空间停止捕获。
https://stackoverflow.com/questions/47219900
复制相似问题