Home > Backend Development > PHP Tutorial > 正则表达式有关问题

正则表达式有关问题

WBOY
Release: 2016-06-13 13:47:32
Original
1017 people have browsed it

正则表达式问题
正则怎样匹配href="xxxabc/efghijk.css"类似这样的字符串中,href="后面的地址不以http开头的字串

比如有两个字符串:



我只想匹配第一个(即href的值不以http开头的), 并把它替换成, 即使相对的链接变成绝对链接地址.
$str = '';
$str = preg_replace("/href=\"((?为什么不行?


------解决方案--------------------
额,我尝试弄了一下,弄不出来,不过建议你一步一步来,比如说用这样的办法





保存在in文件里,用grep慢慢调试

#grep --color -P "href=\"[^h][^\"]*\"" in

Related labels:
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