how to remove some elements from an html file with notepad?











up vote
0
down vote

favorite












I have a Html file containing lists, images and span tags I want to bring name of the images and text between the span tag and remove the rest , I think that there is some Reg Exp that can do this task but I can't figure out how , could you please help , this is a part from my file :





           <a href="text/tirette-a-cable-boite-de-vitesse-manuelle-15187" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15187" data-ga-label="categories" data-category-id="15187" data-parent-id="10338" data-part-type="PKW">
<img alt="Tirette à câble, boîte de vitesse manuelle" src="./pathback/15187.png" class="mCS_img_loaded"> <span>Tirette à câble, boîte de vitesse manuelle</span>
</a>
</li>
<li class="menu-category__second-item">
<a href="text/valve-de-commande-transmission-automatique-15185" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15185" data-ga-label="categories" data-category-id="15185" data-parent-id="10338" data-part-type="PKW">
<img alt="Valve de commande, transmission automatique" src="./pathback/15185.png" class="mCS_img_loaded"> <span>Valve de commande, transmission automatique</span>
</a>
</li>


I want as result to have name image + text content between span tag
something like this :




15187.png+Tirette à câble, boîte de vitesse manuelle




thank you










share|improve this question






















  • HTML and regex are not good friends. Use a parser, it is simpler, faster and much more maintainable. A regex for such job will be terrible.
    – Toto
    Nov 22 at 15:46















up vote
0
down vote

favorite












I have a Html file containing lists, images and span tags I want to bring name of the images and text between the span tag and remove the rest , I think that there is some Reg Exp that can do this task but I can't figure out how , could you please help , this is a part from my file :





           <a href="text/tirette-a-cable-boite-de-vitesse-manuelle-15187" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15187" data-ga-label="categories" data-category-id="15187" data-parent-id="10338" data-part-type="PKW">
<img alt="Tirette à câble, boîte de vitesse manuelle" src="./pathback/15187.png" class="mCS_img_loaded"> <span>Tirette à câble, boîte de vitesse manuelle</span>
</a>
</li>
<li class="menu-category__second-item">
<a href="text/valve-de-commande-transmission-automatique-15185" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15185" data-ga-label="categories" data-category-id="15185" data-parent-id="10338" data-part-type="PKW">
<img alt="Valve de commande, transmission automatique" src="./pathback/15185.png" class="mCS_img_loaded"> <span>Valve de commande, transmission automatique</span>
</a>
</li>


I want as result to have name image + text content between span tag
something like this :




15187.png+Tirette à câble, boîte de vitesse manuelle




thank you










share|improve this question






















  • HTML and regex are not good friends. Use a parser, it is simpler, faster and much more maintainable. A regex for such job will be terrible.
    – Toto
    Nov 22 at 15:46













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a Html file containing lists, images and span tags I want to bring name of the images and text between the span tag and remove the rest , I think that there is some Reg Exp that can do this task but I can't figure out how , could you please help , this is a part from my file :





           <a href="text/tirette-a-cable-boite-de-vitesse-manuelle-15187" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15187" data-ga-label="categories" data-category-id="15187" data-parent-id="10338" data-part-type="PKW">
<img alt="Tirette à câble, boîte de vitesse manuelle" src="./pathback/15187.png" class="mCS_img_loaded"> <span>Tirette à câble, boîte de vitesse manuelle</span>
</a>
</li>
<li class="menu-category__second-item">
<a href="text/valve-de-commande-transmission-automatique-15185" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15185" data-ga-label="categories" data-category-id="15185" data-parent-id="10338" data-part-type="PKW">
<img alt="Valve de commande, transmission automatique" src="./pathback/15185.png" class="mCS_img_loaded"> <span>Valve de commande, transmission automatique</span>
</a>
</li>


I want as result to have name image + text content between span tag
something like this :




15187.png+Tirette à câble, boîte de vitesse manuelle




thank you










share|improve this question













I have a Html file containing lists, images and span tags I want to bring name of the images and text between the span tag and remove the rest , I think that there is some Reg Exp that can do this task but I can't figure out how , could you please help , this is a part from my file :





           <a href="text/tirette-a-cable-boite-de-vitesse-manuelle-15187" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15187" data-ga-label="categories" data-category-id="15187" data-parent-id="10338" data-part-type="PKW">
<img alt="Tirette à câble, boîte de vitesse manuelle" src="./pathback/15187.png" class="mCS_img_loaded"> <span>Tirette à câble, boîte de vitesse manuelle</span>
</a>
</li>
<li class="menu-category__second-item">
<a href="text/valve-de-commande-transmission-automatique-15185" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15185" data-ga-label="categories" data-category-id="15185" data-parent-id="10338" data-part-type="PKW">
<img alt="Valve de commande, transmission automatique" src="./pathback/15185.png" class="mCS_img_loaded"> <span>Valve de commande, transmission automatique</span>
</a>
</li>


I want as result to have name image + text content between span tag
something like this :




15187.png+Tirette à câble, boîte de vitesse manuelle




thank you







notepad++






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 14:43









samran

1




1












  • HTML and regex are not good friends. Use a parser, it is simpler, faster and much more maintainable. A regex for such job will be terrible.
    – Toto
    Nov 22 at 15:46


















  • HTML and regex are not good friends. Use a parser, it is simpler, faster and much more maintainable. A regex for such job will be terrible.
    – Toto
    Nov 22 at 15:46
















HTML and regex are not good friends. Use a parser, it is simpler, faster and much more maintainable. A regex for such job will be terrible.
– Toto
Nov 22 at 15:46




HTML and regex are not good friends. Use a parser, it is simpler, faster and much more maintainable. A regex for such job will be terrible.
– Toto
Nov 22 at 15:46










1 Answer
1






active

oldest

votes

















up vote
0
down vote













You really should write a script that have html parser (like php).



But if you want to do that with Notepad++, here is a way to go:





  • Ctrl+H

  • Find what: <img .*?src="[^"]+/([^/"]+).+?<span>([^<]+)</span>

  • Replace with: $1 $2

  • UNcheck Match case

  • check Wrap around

  • check Regular expression

  • DO NOT CHECK . matches newline

  • Replace all


Explanation:



<img            # literally <img and a space
.*? # 0 or more any character but newline, not greedy
src="[^"]+/ # literally src=" followed by 1 or more non quote then a slash
([^/"]+) # group 1, 1 or more not quote not slash
.+? # 1 or more any character but newline, not greedy
<span> # literally <span>
([^<]+) # group 2, 1 or more any character that is not <
</span> # literally </span>


Replacement:



$1  # content of group 1, filename
# a space
$2 # content of group 2, test inside span


Result for given example:



       <a href="text/tirette-a-cable-boite-de-vitesse-manuelle-15187" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15187" data-ga-label="categories" data-category-id="15187" data-parent-id="10338" data-part-type="PKW">
15187.png Tirette à câble, boîte de vitesse manuelle
</a>
</li>
<li class="menu-category__second-item">
<a href="text/valve-de-commande-transmission-automatique-15185" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15185" data-ga-label="categories" data-category-id="15185" data-parent-id="10338" data-part-type="PKW">
15185.png Valve de commande, transmission automatique
</a>
</li>





share|improve this answer





















    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1377592%2fhow-to-remove-some-elements-from-an-html-file-with-notepad%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    You really should write a script that have html parser (like php).



    But if you want to do that with Notepad++, here is a way to go:





    • Ctrl+H

    • Find what: <img .*?src="[^"]+/([^/"]+).+?<span>([^<]+)</span>

    • Replace with: $1 $2

    • UNcheck Match case

    • check Wrap around

    • check Regular expression

    • DO NOT CHECK . matches newline

    • Replace all


    Explanation:



    <img            # literally <img and a space
    .*? # 0 or more any character but newline, not greedy
    src="[^"]+/ # literally src=" followed by 1 or more non quote then a slash
    ([^/"]+) # group 1, 1 or more not quote not slash
    .+? # 1 or more any character but newline, not greedy
    <span> # literally <span>
    ([^<]+) # group 2, 1 or more any character that is not <
    </span> # literally </span>


    Replacement:



    $1  # content of group 1, filename
    # a space
    $2 # content of group 2, test inside span


    Result for given example:



           <a href="text/tirette-a-cable-boite-de-vitesse-manuelle-15187" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15187" data-ga-label="categories" data-category-id="15187" data-parent-id="10338" data-part-type="PKW">
    15187.png Tirette à câble, boîte de vitesse manuelle
    </a>
    </li>
    <li class="menu-category__second-item">
    <a href="text/valve-de-commande-transmission-automatique-15185" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15185" data-ga-label="categories" data-category-id="15185" data-parent-id="10338" data-part-type="PKW">
    15185.png Valve de commande, transmission automatique
    </a>
    </li>





    share|improve this answer

























      up vote
      0
      down vote













      You really should write a script that have html parser (like php).



      But if you want to do that with Notepad++, here is a way to go:





      • Ctrl+H

      • Find what: <img .*?src="[^"]+/([^/"]+).+?<span>([^<]+)</span>

      • Replace with: $1 $2

      • UNcheck Match case

      • check Wrap around

      • check Regular expression

      • DO NOT CHECK . matches newline

      • Replace all


      Explanation:



      <img            # literally <img and a space
      .*? # 0 or more any character but newline, not greedy
      src="[^"]+/ # literally src=" followed by 1 or more non quote then a slash
      ([^/"]+) # group 1, 1 or more not quote not slash
      .+? # 1 or more any character but newline, not greedy
      <span> # literally <span>
      ([^<]+) # group 2, 1 or more any character that is not <
      </span> # literally </span>


      Replacement:



      $1  # content of group 1, filename
      # a space
      $2 # content of group 2, test inside span


      Result for given example:



             <a href="text/tirette-a-cable-boite-de-vitesse-manuelle-15187" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15187" data-ga-label="categories" data-category-id="15187" data-parent-id="10338" data-part-type="PKW">
      15187.png Tirette à câble, boîte de vitesse manuelle
      </a>
      </li>
      <li class="menu-category__second-item">
      <a href="text/valve-de-commande-transmission-automatique-15185" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15185" data-ga-label="categories" data-category-id="15185" data-parent-id="10338" data-part-type="PKW">
      15185.png Valve de commande, transmission automatique
      </a>
      </li>





      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        You really should write a script that have html parser (like php).



        But if you want to do that with Notepad++, here is a way to go:





        • Ctrl+H

        • Find what: <img .*?src="[^"]+/([^/"]+).+?<span>([^<]+)</span>

        • Replace with: $1 $2

        • UNcheck Match case

        • check Wrap around

        • check Regular expression

        • DO NOT CHECK . matches newline

        • Replace all


        Explanation:



        <img            # literally <img and a space
        .*? # 0 or more any character but newline, not greedy
        src="[^"]+/ # literally src=" followed by 1 or more non quote then a slash
        ([^/"]+) # group 1, 1 or more not quote not slash
        .+? # 1 or more any character but newline, not greedy
        <span> # literally <span>
        ([^<]+) # group 2, 1 or more any character that is not <
        </span> # literally </span>


        Replacement:



        $1  # content of group 1, filename
        # a space
        $2 # content of group 2, test inside span


        Result for given example:



               <a href="text/tirette-a-cable-boite-de-vitesse-manuelle-15187" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15187" data-ga-label="categories" data-category-id="15187" data-parent-id="10338" data-part-type="PKW">
        15187.png Tirette à câble, boîte de vitesse manuelle
        </a>
        </li>
        <li class="menu-category__second-item">
        <a href="text/valve-de-commande-transmission-automatique-15185" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15185" data-ga-label="categories" data-category-id="15185" data-parent-id="10338" data-part-type="PKW">
        15185.png Valve de commande, transmission automatique
        </a>
        </li>





        share|improve this answer












        You really should write a script that have html parser (like php).



        But if you want to do that with Notepad++, here is a way to go:





        • Ctrl+H

        • Find what: <img .*?src="[^"]+/([^/"]+).+?<span>([^<]+)</span>

        • Replace with: $1 $2

        • UNcheck Match case

        • check Wrap around

        • check Regular expression

        • DO NOT CHECK . matches newline

        • Replace all


        Explanation:



        <img            # literally <img and a space
        .*? # 0 or more any character but newline, not greedy
        src="[^"]+/ # literally src=" followed by 1 or more non quote then a slash
        ([^/"]+) # group 1, 1 or more not quote not slash
        .+? # 1 or more any character but newline, not greedy
        <span> # literally <span>
        ([^<]+) # group 2, 1 or more any character that is not <
        </span> # literally </span>


        Replacement:



        $1  # content of group 1, filename
        # a space
        $2 # content of group 2, test inside span


        Result for given example:



               <a href="text/tirette-a-cable-boite-de-vitesse-manuelle-15187" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15187" data-ga-label="categories" data-category-id="15187" data-parent-id="10338" data-part-type="PKW">
        15187.png Tirette à câble, boîte de vitesse manuelle
        </a>
        </li>
        <li class="menu-category__second-item">
        <a href="text/valve-de-commande-transmission-automatique-15185" class="ga-click js--header__cat-link" data-gac="Main_menu_parts_standard" data-ga-action="15185" data-ga-label="categories" data-category-id="15185" data-parent-id="10338" data-part-type="PKW">
        15185.png Valve de commande, transmission automatique
        </a>
        </li>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 at 16:01









        Toto

        3,37191126




        3,37191126






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1377592%2fhow-to-remove-some-elements-from-an-html-file-with-notepad%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Plaza Victoria

            In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

            How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...