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

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

WBOY
Release: 2016-06-06 20:38:47
Original
1074 people have browsed it

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

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

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

如果不是替换成

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

的形式怎么做?

回复内容:

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

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

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

如果不是替换成

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

的形式怎么做?

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

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

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template