PHP regularly removes spaces and

Time:2020-9-27

1. PHP regular remove < p > & nbsp; < / P > spaces & nbsp;


$str='
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong><span style="font-size: 18px;">Factory Supply High Quality Maitake Mushroom Extract Powder Bulk</span></strong></p>
<p>&nbsp;</p>
<p>&nbsp;</p>Product Name
<p>&nbsp;</p>';
 
$uuu=preg_replace("/(\s|\&nbsp\;| |\xc2\xa0)/","",$str);
echo str_replace('<p></p>', '', $uuu);

2. STR of PHP_ How does the replace function replace < p > < br / > < / P >?

$html="<p>fdasf</p>";
  echo $string = str_replace(array("<p>","","</p>"),"",$html);
  br<http://bbs.houdunwang.com/>
If < p > content < / P > is replaced by < p > content < / P > < p > content < / P > (the space is a mixture of tab and space bar), the method is as follows
  $html=preg_ Replace ('/ [",', ', $HTML); // remove the space
If < p > is followed by several, then the content
  <p>Content</p>
  Replace with < p > content</p>
  <p>  content</p>
  Replace with < p > content</p>
  <?php
  $html="<p>
  内容</p>Replace with < p > content</p>
  <p>content</p>Replace with < p > content</p>";方法如下
  $html=trim($html);
  $html=str_replace(PHP_EOL,"",$html);
  $html=str_replace(" ","",$html);
  $html=preg_replace('/\s+/','',$html);
  $html=preg_replace('/[\n\r\t]/','',$html);
  echo "{$html}";
  ?>
str_replace("<p><br\/><\/p>","",$htmlstr);

3. Regular expressions replace or remove < p > < / P > tags in strings

For example: Zhang San < p > AAAA < / P > History < p > BBBB</p>

If you want to replace < p > AAAA < / P >, including the content, replace < p > [^ <] *? < / P > with blank
If you want to replace < p > < / P >, excluding the middle, replace < p > ([^ <] *?) < / P > with $1

4. JS remove the regularity of < p > and < / P > tags


var s='<p>developpaer</p>';
s=s.replace(/<\/?p[^>]*>/gi,'')
alert(s)

5. See here, developeppaer editor to share with you a replacement regular, empty characters are basically all included

str=str.replace(/<p>(\s|\&nbsp\;| | |\xc2\xa0)*<\/p>/ig, “”);

about

<p> &nbsp;    </p>、

p>

&nbsp;

    </p>

Can match

This article about PHP regular remove space article introduced here, more related PHP regular remove space content, please search the previous articles of developeppaer or continue to browse the related articles below, I hope you can support developeppaer more in the future!