我正在使用wordpress的默认“插入视频”功能(只插入视频的普通超链接),并希望用视频播放器之类的其他东西替换该链接。
我的问题是:获取帖子内所有链接的正则表达式模式是什么?谢谢
我正在使用wordpress的默认“插入视频”功能(只插入视频的普通超链接),并希望用视频播放器之类的其他东西替换该链接。
我的问题是:获取帖子内所有链接的正则表达式模式是什么?谢谢
我将在下面回答您的问题,但您是否考虑过使用嵌入?查看此处了解更多信息:http://codex.wordpress.org/Embeds
最简单的正则表达式如下所示http\\:\\/\\/.*\\b
下面是一个实际的例子:
<?php
$file = \'test.txt\';
$fp = fopen($file, \'r\');
$contents = fread($fp, filesize($file));
$matches = array();
preg_match_all(\'/http\\:\\/\\/.*\\b/\', $contents, $matches);
print_r($matches);
?>
我引用的文件如下所示:http://wordpress.stackexchange.com/questions/12809/retrieving-all-links-from-a-post http://www.youtube.com/ http://ca3.php.net/manual/en/function.preg-match.php返回结果如下所示:
Array ( [0] => Array ( [0] => http://wordpress.stackexchange.com/questions/12809/retrieving-all-links-from-a-post [1] => http://www.youtube.com [2] => http://ca3.php.net/manual/en/function.preg-match.php ) )
在我的小部件栏上,我有一个超链接的图像。问题是CSS强调了这一点。如何删除下划线?更新:刚刚注意到这是导致下划线的原因:} .entry a, .secondaryColumn a, #commentsContainer h3 a, .commentlist .comment-author a { border-bottom: 1px solid #ddd; color: #3c6c92; font-weight: bold;