How can I extract specific texts from an HTML file by using Notepad++ or Adobe Dreamweaver?

我的梦境 提交于 2020-06-29 04:07:27

问题


.

I want to extract the ID attribute from an HTML file by using Notepad++ or Dreamweaver. Delete all other texts.

For Eg:

<div id="header" class="header-blue sticky">
<div id="header-message" class="alert alert-dismissible">
<form id="contact-form" class="custom-form" method="POST" action="https://www.google.com">
<input id="your-email" type="email" class="form-email"  placeholder="Your Email">

I want to extract only ID attribute from HTML like this;

id="header"
id="header-message"
id="contact-form"
id="your-email"

So what I can do? Please help me..

.


回答1:


  • Ctrl+H
  • Find what: <\w+[^>]+(id=".+?").*?>
  • Replace with: $1
  • CHECK Wrap around
  • CHECK Regular expression
  • Replace all

Explanation:

<\w+            # opening tag
[^>]+           # 1 or more not >
(id=".+?")      # group 1, id and value
.*?             # 1 or more any character, not greedy
>               # close tag
  

Screenshot (before):

Screenshot (after):



来源:https://stackoverflow.com/questions/62477359/how-can-i-extract-specific-texts-from-an-html-file-by-using-notepad-or-adobe-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!