Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use php regularization to remove redundant tags

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "how to use php regularization to remove redundant tags". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "how to use php regularization to remove redundant tags"!

1. Regular removal of php

Space

$str='

Factory Supply High Quality Maitake Mushroom Extract Powder Bulk

Product Name

'; $uuu=preg_replace ("/ (\ s |\ & nbsp\; | |\ xc2\ xa0) /", ", $str); echo str_replace ('

',', $uuu)

2. How to use the str_replace function of php

And replace it?

$html= "

Fdasf

; echo $string = str_replace (array ("

","

"),", $html); if br is

Content

Replace with

Content

Content

Replace with

Contend

(it is possible for spaces to be mixed by tab and space keys) the method is as follows: $html=preg_replace ('/ [\ n\ r\ t] /',', $html); / / remove spaces if

Followed by several, and then the content.

Content

Replace with

Content

Content

Replace with

Contend

Str_replace ("

",", $htmlstr)

3. The regular expression replaces or removes the

Label

Such as: Zhang San

Aaaa

History

Bbbb

If you want to replace

Aaaa

, including the content, put

[^ / gi,'') alert (s)

5. See here the editor specially shares a replacement rule for you. The empty characters basically include all of them.

Str=str.replace (/

(\ s |\ & nbsp\; |\ xc2\ xa0) * / ig, "")

For

P >

All can be matched.

At this point, I believe you have a deeper understanding of "how to use php regularization to remove redundant tags". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report