简体   繁体   English

仅从HTML获取文本部分

[英]Get only Text part from HTML

I have an HTML page opened in EditPlus.I want to remove all the HTML tags ie all the <> tags from it so that I am only left with the text part.What regex do I need to put to remove these.I tried <.> since . 我在EditPlus中打开了一个HTML页面。我想从中删除所有HTML标记,即所有<>标记,这样我只剩下文本部分。我需要放什么正则表达式删除它们。 。>由于。 means any character but it did not work.Can anyone suggest how I can achieve this? 表示任何字符,但没有用。有人可以建议我如何实现此目标吗?

You may use this regexp to find for all HTML tag 您可以使用此正则表达式查找所有HTML标记

<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>

and replace with $2 并替换为$2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM