Search code examples
jquerynotepad++ocrnotepaddata-entry

How to keep only desired texts "Before and After" in Notepadd + ? Remove all other texts


I have some HTML files. How can I remove all texts before and after class="header" or id="header" attribute. I want to extract all classes like it. For eg:

**These are my HTML codes:**

<div class="row">
<div class="header">
<div class="navigation">
<div class="container">
<div class="footer">

**I want to make abode HTML like:**

class="row"
class="header"
class="navigation"
class="container"
class="footer"

Here keeping my desired texts before and after, and removing all other texts. So what I can do? Anybody can help me.. ?


Solution

  • You could try the following find and replace, in regex mode:

    Find:    <\S+ (class=".*?")>
    Replace: $1
    

    This would capture the class attribute along with its RHS value, and then replace with just this captured quantity.

    Demo