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
notepad++
add a comment |
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
notepad++
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
add a comment |
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
notepad++
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++
notepad++
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
add a comment |
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
add a comment |
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>
add a comment |
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>
add a comment |
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>
add a comment |
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>
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>
answered Nov 22 at 16:01
Toto
3,37191126
3,37191126
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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