search
Homephp教程php手册PHP使用正则表达式清除超链接文本

可以用$str = preg_replace("/]*href=[^>]*>|]*>/i","",$strhtml); 这段来实现需求,如果想要更多解决方法,可以参看以下的。
1、删除内容中的超链接

复制代码 代码如下:


ereg_replace('
]*)>([^','\\2',$content);
ereg_replace("
]*>|","",$content);

2、消除包含特定词的超链接

复制代码 代码如下:


$find="this string is my find";
$string='替换掉了';//将超链接替换成的内容
echo ereg_replace(']*)>([^]*)','\\2',$content);

3、获取超链接文本内容

复制代码 代码如下:


//方法一
preg_match_all('/[nrn]*(check user)[nrn]*(a|a)>/i',$string,$matches);

//方法二
preg_match_all('/check user/i',$string,$matches);
print_r($matches);

//方法三
preg_match_all('/]*>[^/i',$string,$matches);
print_r($matches);

//方法四
preg_match_all('/check user/is',$str,$arr);
print_r($arr);

//方法五
preg_match_all('/check user/is',$str,$arr);
print_r($arr);

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool