Search code examples
htmlnotepad++ocrdreamweaverdata-entry

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


.

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..

.


Solution

    • 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):

    enter image description here

    Screenshot (after):

    enter image description here