来自字符串php preg_match的匹配日期

来自字符串php preg_match的匹配日期,php,regex,Php,Regex,我有一个字符串: $string = "Created on: 06-Sep-08"; 我想匹配日期并将其转换为06/09/2008; 所需的regexp是什么? 谢谢 preg_match('/\:.*/is',...); 然后做一个 strtotime(...) 编辑: 忘了添加偏执狂 preg_match('/\:(.*)/is',$string,$matches); 然后做一个 strtotime(...) 编辑: 忘了添加偏执狂 preg_match('/\:(.*)/is'

我有一个字符串:

$string = "Created on: 06-Sep-08";
我想匹配日期并将其转换为06/09/2008; 所需的regexp是什么?
谢谢

preg_match('/\:.*/is',...);
然后做一个

strtotime(...)
编辑:

忘了添加偏执狂

preg_match('/\:(.*)/is',$string,$matches);
然后做一个

strtotime(...)
编辑:

忘了添加偏执狂

preg_match('/\:(.*)/is',$string,$matches);
这将返回匹配的数组

$matches[0]将包含与完整模式匹配的文本,$matches[1]将包含与第一个捕获的括号子模式匹配的文本,依此类推

这将返回匹配的数组

$matches[0]将包含与完整模式匹配的文本,$matches[1]将包含与第一个捕获的括号子模式匹配的文本,依此类推


这很有效!谢谢。\d和\d之间有什么区别?
\d
匹配数字,而
\d
匹配非数字字符。一个完整的清单可以在这家工厂找到!谢谢。\d和\d之间有什么区别?
\d
匹配数字,而
\d
匹配非数字字符。完整列表可在preg_match('/\:(.*)/is',$string,$matches)中找到;预匹配('/\:(.*)/is',$string,$matches);