Jumat, 29 November 2024

Regex Recipe In Notepad++ 2

Learning Objectives: to count how many HTML class attributes in your webpage document.

Practise this following lesson using your computer:
  1. Open Notepad++.
  2. Type this following source code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <style>
    .city {
    background-color: tomato;
    color: white;
    border: 2px solid black;
    margin: 20px;
    padding: 20px;
    }
    </style>
    </head>
    <body>

    <div class="city">
    <h2>London</h2>
    <p>London is the capital of England.</p>
    </div>

    <div class="city">
    <h2>Paris</h2>
    <p>Paris is the capital of France.</p>
    </div>

    <div class="city">
    <h2>Tokyo</h2>
    <p>Tokyo is the capital of Japan.</p>
    </div>

    </body>
    </html>

  3. Click Search > Find... menu.
  4. Ensure you are in the Find tab.
  5. Type this in Find what:
    (<.+? )(?<!>)(class)?=".+?"
    or
    (class)?=".+?"(?!<)(?=.*?)
  6. Check list the Wrap around.
  7. In Search Mode, choose Regular expression (on the below).
  8. press Count button.
  9. It will be display how many class attributes in Find dialogue box status bar.

Notes: you can use the other tools beside Notepad++, to use Regular expression.

text editor, notepad plus plus, regular expression editor, regex editor, regex tools, ellipsis

Bibliography

https://foundry.co/
https://notepad-plus-plus.org/
https://www.hostinger.co.id/
https://www.linguisticsweb.org/
https://www.w3schools.com/

Related Post

Tidak ada komentar:

Posting Komentar

Various Other Posts