How to implement PHP regular matching that does not contain a certain character

藏色散人
Release: 2023-03-04 06:00:01
Original
3344 people have browsed it

How to implement php regular matching that does not contain a certain character: first create a PHP sample file; then enter the statement "$search = '/<([^<]*?)>/is ';preg_match_all($search,$str,$r);"; Finally, execute the file.

How to implement PHP regular matching that does not contain a certain character

Recommended: "PHP Video Tutorial"

php Regular matching content does not include A certain character

Specific question:

I need to match characters that include < >, but they cannot contain <

For example:

Hello customer, I recommend the following projects to you: > and

I want to match and

Implementation method:

<?php
$str = &#39;客户您好,为您推荐以下项目:<项目2:项目名称<项目3:项目名称>>以及<项目1:项目名称>&#39;;
$search = &#39;/<([^<]*?)>/is&#39;;
preg_match_all($search,$str,$r);
echo &#39;<pre class="brush:php;toolbar:false">&#39;;
print_r($r);
echo &#39;
'; ?>
Copy after login

The above is the detailed content of How to implement PHP regular matching that does not contain a certain character. For more information, please follow other related articles on the PHP Chinese website!

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