Home » Php » c# – Get HTML tags from string with regex

c# – Get HTML tags from string with regex

Posted by: admin February 25, 2020 Leave a comment

Questions:

I want to get html tag from the string.

I have tried this regex:

"<[\r\n ]*/?[\r\n ]*(.*?)[\r\n ]*/?[\r\n ]*>"

But it is also giving me:

< / table />

I don’t want such wrong tags.

How to&Answers:

Try </?[^>/]*>|<[^>/]*/> or </?[^>/]+>|<[^>/]+/>. Google is your friend as well.