Home >Backend Development >PHP Tutorial >用正则表达式判断是不是指定的url,怎么写?

用正则表达式判断是不是指定的url,怎么写?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-06 20:38:471093browse

<code>$url="http://www.jsfiddle.net/xxxx/xxxx"
</code>

要首先判断$url 是jsfiddle 的url 那么替换成

<code><iframe src="%5C%22%24url%5C%22"></iframe>
</code>

如果不是替换成

<code><a href="%5C%22%24url%5C%22"></a>
</code>

的形式怎么做?

回复内容:

<code>$url="http://www.jsfiddle.net/xxxx/xxxx"
</code>

要首先判断$url 是jsfiddle 的url 那么替换成

<code><iframe src="%5C%22%24url%5C%22"></iframe>
</code>

如果不是替换成

<code><a href="%5C%22%24url%5C%22"></a>
</code>

的形式怎么做?

http://segmentfault.com/q/1010000002506593/a-1020000002506707 我不是都写出来了么=_=!还单提一个问题出来,真想差评诶。

而且 URL 不能仅仅只判断是不是 jsfiddle 的啊,能用 iframe 嵌入的 URL 格式也是特定的,比如 http://jsfiddle.net 这个就没有意义啊...

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn