问题描述
我想使用REGEX以两种不同的方式定位CITE标记,具体取决于它是否在URL中:
- 如果标签位于URL中,则以www或http开头的标签都可以删除;
- 如果该标签不在URL中,请保持完整标签
这是我要操作的字符串:
www.os<cite>map</cite>s.ordnancesurvey.co.uk/os<cite>map</cite>s/
and the normal text <cite>map</cite> here and again <cite>map</cite> here
http://os<cite>map</cite>s.ordnancesurvey.co.uk/os<cite>map</cite>s/
and the normal text <cite>map</cite> here and again <cite>map</cite> here
我一直在使用这个表达式:
$this_record = preg_replace('/((www.)|(https?:\/\/))([^\s]*?)(<cite>([^\s]*?)<\/cite>)([^\s]*)/','$2$3$4$6$7',$this_record);
这有效,但仅适用于第一组标记并导致:
www.osmaps.ordnancesurvey.co.uk/os<cite>map</cite>s/
and the normal text <cite>map</cite> here and again <cite>map</cite> here
http://osmaps.ordnancesurvey.co.uk/os<cite>map</cite>s/
and the normal text <cite>map</cite> here and again <cite>map</cite> here
URL中仅删除第一组标签。我该如何删除后续的?
非常感谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)