Hướng dẫn replace html tag php

I have thousands of static HTML lines in a text file and I want to keep the "H-number" value that is between a specific HTML tag called "num" and turn it into a link by using PHP. For example, the HTML strings look like this:


H7585...

From this I want to get the part H7585 and turn it into something like this keeping the "H-number" value:


H7585...

However, all the "H-number" codes like H7585 are different, and they are not inside a PHP variable since everything is a string of HTML text. I have tried the PHP functions preg_match and preg_replace but I can't come up with a solution.

Something I have tried is this. But I don't know how to get the different H-number values to show or display:

$string = '...
H7585......
H72000......
H8525...';
- [there are thousands of lines like this though, with different H-number codes].

$string = preg_replace["/[.+?]/is", "display_value_here", $string];

$echo $string;

Would anyone please help me? I would really appreciate it.

I have a string in which there are continous occurances of a font tag

Nội dung chính

  • Not the answer you're looking for? Browse other questions tagged javascript html angularjs node.js replace or ask your own question.
  • How do you replace a tag in HTML?
  • How do you remove HTML tags in HTML?

 DATA ENTRY 

and in some cases like this

 DATA ENTRY 

I want to replace the 2 tags with

So that it looks like this

     

DATA ENTRY

I tried this ,can anyone please suggest me help.Thanks.

 text = text.replace['

Chủ Đề