regex: Select all lines that do not end with a specific tag












0















I have this 4 lines, all starting with tag <p class="TEST"> and ending with tag <br> except the last two.



<p class="TEST">My mother is at home.<br>
<p class="TEST">My father is at home.<br>
<p class="TEXT">My sister is at home.<LLbr>
<p class="TEXT">My brother is at home.<AAbr>


So, I want to find all lines with TEXT tag that doesn't ending with <br>



My output result should be



<p class="TEXT">My sister is at home.<LLbr>
<p class="TEXT">My brother is at home.<AAbr>


I made a regex, but is not too good.
(?-s)(.*<p class="TEXT">.*)(?-s)(?!)<br>(.*)$










share|improve this question

























  • One option, that might give you what you want. If you Ctrl-F to bring up the search dialog, then click on the Mark tab. Check the Bookmark line option and search for <br> or whatever you need to mark the line. Then go to Search - Bookmark and select inverse bookmark. I find this workflow helpful in many scenarios. Hope it helps.

    – HelpingHand
    Dec 27 '18 at 22:42













  • I have more than 5000 .html files to check :) I don't have time to check each individually :)

    – Just Me
    Dec 28 '18 at 10:11
















0















I have this 4 lines, all starting with tag <p class="TEST"> and ending with tag <br> except the last two.



<p class="TEST">My mother is at home.<br>
<p class="TEST">My father is at home.<br>
<p class="TEXT">My sister is at home.<LLbr>
<p class="TEXT">My brother is at home.<AAbr>


So, I want to find all lines with TEXT tag that doesn't ending with <br>



My output result should be



<p class="TEXT">My sister is at home.<LLbr>
<p class="TEXT">My brother is at home.<AAbr>


I made a regex, but is not too good.
(?-s)(.*<p class="TEXT">.*)(?-s)(?!)<br>(.*)$










share|improve this question

























  • One option, that might give you what you want. If you Ctrl-F to bring up the search dialog, then click on the Mark tab. Check the Bookmark line option and search for <br> or whatever you need to mark the line. Then go to Search - Bookmark and select inverse bookmark. I find this workflow helpful in many scenarios. Hope it helps.

    – HelpingHand
    Dec 27 '18 at 22:42













  • I have more than 5000 .html files to check :) I don't have time to check each individually :)

    – Just Me
    Dec 28 '18 at 10:11














0












0








0








I have this 4 lines, all starting with tag <p class="TEST"> and ending with tag <br> except the last two.



<p class="TEST">My mother is at home.<br>
<p class="TEST">My father is at home.<br>
<p class="TEXT">My sister is at home.<LLbr>
<p class="TEXT">My brother is at home.<AAbr>


So, I want to find all lines with TEXT tag that doesn't ending with <br>



My output result should be



<p class="TEXT">My sister is at home.<LLbr>
<p class="TEXT">My brother is at home.<AAbr>


I made a regex, but is not too good.
(?-s)(.*<p class="TEXT">.*)(?-s)(?!)<br>(.*)$










share|improve this question
















I have this 4 lines, all starting with tag <p class="TEST"> and ending with tag <br> except the last two.



<p class="TEST">My mother is at home.<br>
<p class="TEST">My father is at home.<br>
<p class="TEXT">My sister is at home.<LLbr>
<p class="TEXT">My brother is at home.<AAbr>


So, I want to find all lines with TEXT tag that doesn't ending with <br>



My output result should be



<p class="TEXT">My sister is at home.<LLbr>
<p class="TEXT">My brother is at home.<AAbr>


I made a regex, but is not too good.
(?-s)(.*<p class="TEXT">.*)(?-s)(?!)<br>(.*)$







windows-10 notepad++ regex






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 28 '18 at 10:23







Just Me

















asked Dec 27 '18 at 21:41









Just MeJust Me

1819




1819













  • One option, that might give you what you want. If you Ctrl-F to bring up the search dialog, then click on the Mark tab. Check the Bookmark line option and search for <br> or whatever you need to mark the line. Then go to Search - Bookmark and select inverse bookmark. I find this workflow helpful in many scenarios. Hope it helps.

    – HelpingHand
    Dec 27 '18 at 22:42













  • I have more than 5000 .html files to check :) I don't have time to check each individually :)

    – Just Me
    Dec 28 '18 at 10:11



















  • One option, that might give you what you want. If you Ctrl-F to bring up the search dialog, then click on the Mark tab. Check the Bookmark line option and search for <br> or whatever you need to mark the line. Then go to Search - Bookmark and select inverse bookmark. I find this workflow helpful in many scenarios. Hope it helps.

    – HelpingHand
    Dec 27 '18 at 22:42













  • I have more than 5000 .html files to check :) I don't have time to check each individually :)

    – Just Me
    Dec 28 '18 at 10:11

















One option, that might give you what you want. If you Ctrl-F to bring up the search dialog, then click on the Mark tab. Check the Bookmark line option and search for <br> or whatever you need to mark the line. Then go to Search - Bookmark and select inverse bookmark. I find this workflow helpful in many scenarios. Hope it helps.

– HelpingHand
Dec 27 '18 at 22:42







One option, that might give you what you want. If you Ctrl-F to bring up the search dialog, then click on the Mark tab. Check the Bookmark line option and search for <br> or whatever you need to mark the line. Then go to Search - Bookmark and select inverse bookmark. I find this workflow helpful in many scenarios. Hope it helps.

– HelpingHand
Dec 27 '18 at 22:42















I have more than 5000 .html files to check :) I don't have time to check each individually :)

– Just Me
Dec 28 '18 at 10:11





I have more than 5000 .html files to check :) I don't have time to check each individually :)

– Just Me
Dec 28 '18 at 10:11










1 Answer
1






active

oldest

votes


















3
















  • Ctrl+H

  • Find what: <p class="TEXT">(?:(?!<br>)(?!<p).)*(?:<.+?>|z)

  • UNcheck Match case

  • check Wrap around

  • check Regular expression

  • UNCHECK . matches newline

  • Search in document


Explanation:



<p class="TEXT">    # literally
(?: # start non capture group
(?!<br>) # negative lookahead, make sure we haven't <br>
(?!<p) # negative lookahead, make sure we haven't <p
. # any character but newline
)* # group may appear 0 or more times
(?: # non capture group
<.+?> # a tag
| # OR
z # end of string
) # end of group


enter image description here



DEMO






share|improve this answer


























  • hello Toto, thanks a lot. But, another scenario.Suppose the <br> tag is on the next line, and I don't want to find also this because has <br>. See this link regex101.com/r/vSfrsv/2

    – Just Me
    Dec 28 '18 at 14:29











  • @JustMe: See updated demo

    – Toto
    Dec 28 '18 at 15:48











  • thank you, Toto. Please, update your answer with this alternative regex solution here, in case anyone need it. And also, please explain what means this part of regex: (?!<p).)*(?:<.+?>|z)

    – Just Me
    Dec 28 '18 at 16:42













  • @JustMe: edit done.

    – Toto
    Dec 28 '18 at 17:01











  • please see this real case. regex101.com/r/y8GB6e/1 I change a little bit your regex, with my real tags. But is not working. Please help me, and change the good version on the link below. Instead of <br> I have </p>

    – Just Me
    Dec 28 '18 at 19:05













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',
autoActivateHeartbeat: false,
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%2f1388239%2fregex-select-all-lines-that-do-not-end-with-a-specific-tag%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









3
















  • Ctrl+H

  • Find what: <p class="TEXT">(?:(?!<br>)(?!<p).)*(?:<.+?>|z)

  • UNcheck Match case

  • check Wrap around

  • check Regular expression

  • UNCHECK . matches newline

  • Search in document


Explanation:



<p class="TEXT">    # literally
(?: # start non capture group
(?!<br>) # negative lookahead, make sure we haven't <br>
(?!<p) # negative lookahead, make sure we haven't <p
. # any character but newline
)* # group may appear 0 or more times
(?: # non capture group
<.+?> # a tag
| # OR
z # end of string
) # end of group


enter image description here



DEMO






share|improve this answer


























  • hello Toto, thanks a lot. But, another scenario.Suppose the <br> tag is on the next line, and I don't want to find also this because has <br>. See this link regex101.com/r/vSfrsv/2

    – Just Me
    Dec 28 '18 at 14:29











  • @JustMe: See updated demo

    – Toto
    Dec 28 '18 at 15:48











  • thank you, Toto. Please, update your answer with this alternative regex solution here, in case anyone need it. And also, please explain what means this part of regex: (?!<p).)*(?:<.+?>|z)

    – Just Me
    Dec 28 '18 at 16:42













  • @JustMe: edit done.

    – Toto
    Dec 28 '18 at 17:01











  • please see this real case. regex101.com/r/y8GB6e/1 I change a little bit your regex, with my real tags. But is not working. Please help me, and change the good version on the link below. Instead of <br> I have </p>

    – Just Me
    Dec 28 '18 at 19:05


















3
















  • Ctrl+H

  • Find what: <p class="TEXT">(?:(?!<br>)(?!<p).)*(?:<.+?>|z)

  • UNcheck Match case

  • check Wrap around

  • check Regular expression

  • UNCHECK . matches newline

  • Search in document


Explanation:



<p class="TEXT">    # literally
(?: # start non capture group
(?!<br>) # negative lookahead, make sure we haven't <br>
(?!<p) # negative lookahead, make sure we haven't <p
. # any character but newline
)* # group may appear 0 or more times
(?: # non capture group
<.+?> # a tag
| # OR
z # end of string
) # end of group


enter image description here



DEMO






share|improve this answer


























  • hello Toto, thanks a lot. But, another scenario.Suppose the <br> tag is on the next line, and I don't want to find also this because has <br>. See this link regex101.com/r/vSfrsv/2

    – Just Me
    Dec 28 '18 at 14:29











  • @JustMe: See updated demo

    – Toto
    Dec 28 '18 at 15:48











  • thank you, Toto. Please, update your answer with this alternative regex solution here, in case anyone need it. And also, please explain what means this part of regex: (?!<p).)*(?:<.+?>|z)

    – Just Me
    Dec 28 '18 at 16:42













  • @JustMe: edit done.

    – Toto
    Dec 28 '18 at 17:01











  • please see this real case. regex101.com/r/y8GB6e/1 I change a little bit your regex, with my real tags. But is not working. Please help me, and change the good version on the link below. Instead of <br> I have </p>

    – Just Me
    Dec 28 '18 at 19:05
















3












3








3









  • Ctrl+H

  • Find what: <p class="TEXT">(?:(?!<br>)(?!<p).)*(?:<.+?>|z)

  • UNcheck Match case

  • check Wrap around

  • check Regular expression

  • UNCHECK . matches newline

  • Search in document


Explanation:



<p class="TEXT">    # literally
(?: # start non capture group
(?!<br>) # negative lookahead, make sure we haven't <br>
(?!<p) # negative lookahead, make sure we haven't <p
. # any character but newline
)* # group may appear 0 or more times
(?: # non capture group
<.+?> # a tag
| # OR
z # end of string
) # end of group


enter image description here



DEMO






share|improve this answer

















  • Ctrl+H

  • Find what: <p class="TEXT">(?:(?!<br>)(?!<p).)*(?:<.+?>|z)

  • UNcheck Match case

  • check Wrap around

  • check Regular expression

  • UNCHECK . matches newline

  • Search in document


Explanation:



<p class="TEXT">    # literally
(?: # start non capture group
(?!<br>) # negative lookahead, make sure we haven't <br>
(?!<p) # negative lookahead, make sure we haven't <p
. # any character but newline
)* # group may appear 0 or more times
(?: # non capture group
<.+?> # a tag
| # OR
z # end of string
) # end of group


enter image description here



DEMO







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 28 '18 at 17:01

























answered Dec 28 '18 at 10:42









TotoToto

3,763101226




3,763101226













  • hello Toto, thanks a lot. But, another scenario.Suppose the <br> tag is on the next line, and I don't want to find also this because has <br>. See this link regex101.com/r/vSfrsv/2

    – Just Me
    Dec 28 '18 at 14:29











  • @JustMe: See updated demo

    – Toto
    Dec 28 '18 at 15:48











  • thank you, Toto. Please, update your answer with this alternative regex solution here, in case anyone need it. And also, please explain what means this part of regex: (?!<p).)*(?:<.+?>|z)

    – Just Me
    Dec 28 '18 at 16:42













  • @JustMe: edit done.

    – Toto
    Dec 28 '18 at 17:01











  • please see this real case. regex101.com/r/y8GB6e/1 I change a little bit your regex, with my real tags. But is not working. Please help me, and change the good version on the link below. Instead of <br> I have </p>

    – Just Me
    Dec 28 '18 at 19:05





















  • hello Toto, thanks a lot. But, another scenario.Suppose the <br> tag is on the next line, and I don't want to find also this because has <br>. See this link regex101.com/r/vSfrsv/2

    – Just Me
    Dec 28 '18 at 14:29











  • @JustMe: See updated demo

    – Toto
    Dec 28 '18 at 15:48











  • thank you, Toto. Please, update your answer with this alternative regex solution here, in case anyone need it. And also, please explain what means this part of regex: (?!<p).)*(?:<.+?>|z)

    – Just Me
    Dec 28 '18 at 16:42













  • @JustMe: edit done.

    – Toto
    Dec 28 '18 at 17:01











  • please see this real case. regex101.com/r/y8GB6e/1 I change a little bit your regex, with my real tags. But is not working. Please help me, and change the good version on the link below. Instead of <br> I have </p>

    – Just Me
    Dec 28 '18 at 19:05



















hello Toto, thanks a lot. But, another scenario.Suppose the <br> tag is on the next line, and I don't want to find also this because has <br>. See this link regex101.com/r/vSfrsv/2

– Just Me
Dec 28 '18 at 14:29





hello Toto, thanks a lot. But, another scenario.Suppose the <br> tag is on the next line, and I don't want to find also this because has <br>. See this link regex101.com/r/vSfrsv/2

– Just Me
Dec 28 '18 at 14:29













@JustMe: See updated demo

– Toto
Dec 28 '18 at 15:48





@JustMe: See updated demo

– Toto
Dec 28 '18 at 15:48













thank you, Toto. Please, update your answer with this alternative regex solution here, in case anyone need it. And also, please explain what means this part of regex: (?!<p).)*(?:<.+?>|z)

– Just Me
Dec 28 '18 at 16:42







thank you, Toto. Please, update your answer with this alternative regex solution here, in case anyone need it. And also, please explain what means this part of regex: (?!<p).)*(?:<.+?>|z)

– Just Me
Dec 28 '18 at 16:42















@JustMe: edit done.

– Toto
Dec 28 '18 at 17:01





@JustMe: edit done.

– Toto
Dec 28 '18 at 17:01













please see this real case. regex101.com/r/y8GB6e/1 I change a little bit your regex, with my real tags. But is not working. Please help me, and change the good version on the link below. Instead of <br> I have </p>

– Just Me
Dec 28 '18 at 19:05







please see this real case. regex101.com/r/y8GB6e/1 I change a little bit your regex, with my real tags. But is not working. Please help me, and change the good version on the link below. Instead of <br> I have </p>

– Just Me
Dec 28 '18 at 19:05




















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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1388239%2fregex-select-all-lines-that-do-not-end-with-a-specific-tag%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

Список кардиналов, возведённых папой римским Каликстом III

Deduzione

Mysql.sock missing - “Can't connect to local MySQL server through socket”