Regex: Select all lines that do not contain some particular words in front of another particular words (tags)












0















I want to find a regex formula as to select all line that does not have <p class="test_formal"> in front of <span class="test_formal2">



<p class="test_formal"><span class="test_formal2">



I made a regex, but is not too good.



(?s)A(?!.*?(?<!w)(<span class="test_formal2">)(?!w)<p class="test_formal">).*



Can anyone help me a little bit?










share|improve this question



























    0















    I want to find a regex formula as to select all line that does not have <p class="test_formal"> in front of <span class="test_formal2">



    <p class="test_formal"><span class="test_formal2">



    I made a regex, but is not too good.



    (?s)A(?!.*?(?<!w)(<span class="test_formal2">)(?!w)<p class="test_formal">).*



    Can anyone help me a little bit?










    share|improve this question

























      0












      0








      0








      I want to find a regex formula as to select all line that does not have <p class="test_formal"> in front of <span class="test_formal2">



      <p class="test_formal"><span class="test_formal2">



      I made a regex, but is not too good.



      (?s)A(?!.*?(?<!w)(<span class="test_formal2">)(?!w)<p class="test_formal">).*



      Can anyone help me a little bit?










      share|improve this question














      I want to find a regex formula as to select all line that does not have <p class="test_formal"> in front of <span class="test_formal2">



      <p class="test_formal"><span class="test_formal2">



      I made a regex, but is not too good.



      (?s)A(?!.*?(?<!w)(<span class="test_formal2">)(?!w)<p class="test_formal">).*



      Can anyone help me a little bit?







      windows-10 notepad++ regex






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 30 '18 at 11:06









      Rob RobRob Rob

      32




      32






















          1 Answer
          1






          active

          oldest

          votes


















          2














          This will match all lines that have:



          <span class="test_formal2"> followed or not by <p class="test_formal">



          But not <p class="test_formal"> followed by <span class="test_formal2">





          • Ctrl+F

          • Find what: ^(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*$

          • check Wrap around

          • check Regular expression

          • UNCHECK . matches newline

          • Search in document


          Explanation:



          ^                               # beginning of line
          (?: # start non capture group
          (?! # negative lookahead, make sure we haven't
          <p class="test_formal"> # literally
          ) # end lookahead
          . # 1 any character
          )* # end group, may appear 0 or more times
          <span class="test_formal2"> # literally
          .* # 0 or more any character
          $ # end of line


          Given:



          <p class="test_formal">
          <span class="test_formal2">
          <p class="test_formal"><span class="test_formal2">
          blah blah <p class="test_formal"><span class="test_formal2"> blah blah
          <span class="test_formal2"><p class="test_formal">
          blah blah <span class="test_formal2"><p class="test_formal"> blah blah


          It matches:



          Search "^(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*$" (3 hits in 1 file)
          new 2 (3 hits)
          Line 2: <span class="test_formal2">
          Line 5: <span class="test_formal2"><p class="test_formal">
          Line 6: blah blah <span class="test_formal2"><p class="test_formal"> blah blah


          Regex101 Demo






          share|improve this answer


























          • thank you, Toto. But there is a small problem. The regex should find only those line which necessarily contain <span class="test_formal2"> . So, your regex selects inverse, first of all those line that contains <p class="test_formal">. See this update regex101.com/r/YEcK8e/2

            – Rob Rob
            Dec 30 '18 at 15:05











          • ok, I find the problem. Update a little bit your regex, just add ! in fist paranthesis, right before <p class="test_formal">. Works. So, please update your regex answer with this ^(?:(?:.*?!<p class="test_formal">(?:(?!<span class="test_formal2">).)*)|(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*)$

            – Rob Rob
            Dec 30 '18 at 15:33











          • @RobRob: That wasn't clear. I've completely rewrite the regex, it's now really simplifed.

            – Toto
            Dec 30 '18 at 16:23











          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%2f1388939%2fregex-select-all-lines-that-do-not-contain-some-particular-words-in-front-of-an%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









          2














          This will match all lines that have:



          <span class="test_formal2"> followed or not by <p class="test_formal">



          But not <p class="test_formal"> followed by <span class="test_formal2">





          • Ctrl+F

          • Find what: ^(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*$

          • check Wrap around

          • check Regular expression

          • UNCHECK . matches newline

          • Search in document


          Explanation:



          ^                               # beginning of line
          (?: # start non capture group
          (?! # negative lookahead, make sure we haven't
          <p class="test_formal"> # literally
          ) # end lookahead
          . # 1 any character
          )* # end group, may appear 0 or more times
          <span class="test_formal2"> # literally
          .* # 0 or more any character
          $ # end of line


          Given:



          <p class="test_formal">
          <span class="test_formal2">
          <p class="test_formal"><span class="test_formal2">
          blah blah <p class="test_formal"><span class="test_formal2"> blah blah
          <span class="test_formal2"><p class="test_formal">
          blah blah <span class="test_formal2"><p class="test_formal"> blah blah


          It matches:



          Search "^(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*$" (3 hits in 1 file)
          new 2 (3 hits)
          Line 2: <span class="test_formal2">
          Line 5: <span class="test_formal2"><p class="test_formal">
          Line 6: blah blah <span class="test_formal2"><p class="test_formal"> blah blah


          Regex101 Demo






          share|improve this answer


























          • thank you, Toto. But there is a small problem. The regex should find only those line which necessarily contain <span class="test_formal2"> . So, your regex selects inverse, first of all those line that contains <p class="test_formal">. See this update regex101.com/r/YEcK8e/2

            – Rob Rob
            Dec 30 '18 at 15:05











          • ok, I find the problem. Update a little bit your regex, just add ! in fist paranthesis, right before <p class="test_formal">. Works. So, please update your regex answer with this ^(?:(?:.*?!<p class="test_formal">(?:(?!<span class="test_formal2">).)*)|(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*)$

            – Rob Rob
            Dec 30 '18 at 15:33











          • @RobRob: That wasn't clear. I've completely rewrite the regex, it's now really simplifed.

            – Toto
            Dec 30 '18 at 16:23
















          2














          This will match all lines that have:



          <span class="test_formal2"> followed or not by <p class="test_formal">



          But not <p class="test_formal"> followed by <span class="test_formal2">





          • Ctrl+F

          • Find what: ^(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*$

          • check Wrap around

          • check Regular expression

          • UNCHECK . matches newline

          • Search in document


          Explanation:



          ^                               # beginning of line
          (?: # start non capture group
          (?! # negative lookahead, make sure we haven't
          <p class="test_formal"> # literally
          ) # end lookahead
          . # 1 any character
          )* # end group, may appear 0 or more times
          <span class="test_formal2"> # literally
          .* # 0 or more any character
          $ # end of line


          Given:



          <p class="test_formal">
          <span class="test_formal2">
          <p class="test_formal"><span class="test_formal2">
          blah blah <p class="test_formal"><span class="test_formal2"> blah blah
          <span class="test_formal2"><p class="test_formal">
          blah blah <span class="test_formal2"><p class="test_formal"> blah blah


          It matches:



          Search "^(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*$" (3 hits in 1 file)
          new 2 (3 hits)
          Line 2: <span class="test_formal2">
          Line 5: <span class="test_formal2"><p class="test_formal">
          Line 6: blah blah <span class="test_formal2"><p class="test_formal"> blah blah


          Regex101 Demo






          share|improve this answer


























          • thank you, Toto. But there is a small problem. The regex should find only those line which necessarily contain <span class="test_formal2"> . So, your regex selects inverse, first of all those line that contains <p class="test_formal">. See this update regex101.com/r/YEcK8e/2

            – Rob Rob
            Dec 30 '18 at 15:05











          • ok, I find the problem. Update a little bit your regex, just add ! in fist paranthesis, right before <p class="test_formal">. Works. So, please update your regex answer with this ^(?:(?:.*?!<p class="test_formal">(?:(?!<span class="test_formal2">).)*)|(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*)$

            – Rob Rob
            Dec 30 '18 at 15:33











          • @RobRob: That wasn't clear. I've completely rewrite the regex, it's now really simplifed.

            – Toto
            Dec 30 '18 at 16:23














          2












          2








          2







          This will match all lines that have:



          <span class="test_formal2"> followed or not by <p class="test_formal">



          But not <p class="test_formal"> followed by <span class="test_formal2">





          • Ctrl+F

          • Find what: ^(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*$

          • check Wrap around

          • check Regular expression

          • UNCHECK . matches newline

          • Search in document


          Explanation:



          ^                               # beginning of line
          (?: # start non capture group
          (?! # negative lookahead, make sure we haven't
          <p class="test_formal"> # literally
          ) # end lookahead
          . # 1 any character
          )* # end group, may appear 0 or more times
          <span class="test_formal2"> # literally
          .* # 0 or more any character
          $ # end of line


          Given:



          <p class="test_formal">
          <span class="test_formal2">
          <p class="test_formal"><span class="test_formal2">
          blah blah <p class="test_formal"><span class="test_formal2"> blah blah
          <span class="test_formal2"><p class="test_formal">
          blah blah <span class="test_formal2"><p class="test_formal"> blah blah


          It matches:



          Search "^(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*$" (3 hits in 1 file)
          new 2 (3 hits)
          Line 2: <span class="test_formal2">
          Line 5: <span class="test_formal2"><p class="test_formal">
          Line 6: blah blah <span class="test_formal2"><p class="test_formal"> blah blah


          Regex101 Demo






          share|improve this answer















          This will match all lines that have:



          <span class="test_formal2"> followed or not by <p class="test_formal">



          But not <p class="test_formal"> followed by <span class="test_formal2">





          • Ctrl+F

          • Find what: ^(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*$

          • check Wrap around

          • check Regular expression

          • UNCHECK . matches newline

          • Search in document


          Explanation:



          ^                               # beginning of line
          (?: # start non capture group
          (?! # negative lookahead, make sure we haven't
          <p class="test_formal"> # literally
          ) # end lookahead
          . # 1 any character
          )* # end group, may appear 0 or more times
          <span class="test_formal2"> # literally
          .* # 0 or more any character
          $ # end of line


          Given:



          <p class="test_formal">
          <span class="test_formal2">
          <p class="test_formal"><span class="test_formal2">
          blah blah <p class="test_formal"><span class="test_formal2"> blah blah
          <span class="test_formal2"><p class="test_formal">
          blah blah <span class="test_formal2"><p class="test_formal"> blah blah


          It matches:



          Search "^(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*$" (3 hits in 1 file)
          new 2 (3 hits)
          Line 2: <span class="test_formal2">
          Line 5: <span class="test_formal2"><p class="test_formal">
          Line 6: blah blah <span class="test_formal2"><p class="test_formal"> blah blah


          Regex101 Demo







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 30 '18 at 16:23

























          answered Dec 30 '18 at 13:51









          TotoToto

          3,735101226




          3,735101226













          • thank you, Toto. But there is a small problem. The regex should find only those line which necessarily contain <span class="test_formal2"> . So, your regex selects inverse, first of all those line that contains <p class="test_formal">. See this update regex101.com/r/YEcK8e/2

            – Rob Rob
            Dec 30 '18 at 15:05











          • ok, I find the problem. Update a little bit your regex, just add ! in fist paranthesis, right before <p class="test_formal">. Works. So, please update your regex answer with this ^(?:(?:.*?!<p class="test_formal">(?:(?!<span class="test_formal2">).)*)|(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*)$

            – Rob Rob
            Dec 30 '18 at 15:33











          • @RobRob: That wasn't clear. I've completely rewrite the regex, it's now really simplifed.

            – Toto
            Dec 30 '18 at 16:23



















          • thank you, Toto. But there is a small problem. The regex should find only those line which necessarily contain <span class="test_formal2"> . So, your regex selects inverse, first of all those line that contains <p class="test_formal">. See this update regex101.com/r/YEcK8e/2

            – Rob Rob
            Dec 30 '18 at 15:05











          • ok, I find the problem. Update a little bit your regex, just add ! in fist paranthesis, right before <p class="test_formal">. Works. So, please update your regex answer with this ^(?:(?:.*?!<p class="test_formal">(?:(?!<span class="test_formal2">).)*)|(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*)$

            – Rob Rob
            Dec 30 '18 at 15:33











          • @RobRob: That wasn't clear. I've completely rewrite the regex, it's now really simplifed.

            – Toto
            Dec 30 '18 at 16:23

















          thank you, Toto. But there is a small problem. The regex should find only those line which necessarily contain <span class="test_formal2"> . So, your regex selects inverse, first of all those line that contains <p class="test_formal">. See this update regex101.com/r/YEcK8e/2

          – Rob Rob
          Dec 30 '18 at 15:05





          thank you, Toto. But there is a small problem. The regex should find only those line which necessarily contain <span class="test_formal2"> . So, your regex selects inverse, first of all those line that contains <p class="test_formal">. See this update regex101.com/r/YEcK8e/2

          – Rob Rob
          Dec 30 '18 at 15:05













          ok, I find the problem. Update a little bit your regex, just add ! in fist paranthesis, right before <p class="test_formal">. Works. So, please update your regex answer with this ^(?:(?:.*?!<p class="test_formal">(?:(?!<span class="test_formal2">).)*)|(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*)$

          – Rob Rob
          Dec 30 '18 at 15:33





          ok, I find the problem. Update a little bit your regex, just add ! in fist paranthesis, right before <p class="test_formal">. Works. So, please update your regex answer with this ^(?:(?:.*?!<p class="test_formal">(?:(?!<span class="test_formal2">).)*)|(?:(?!<p class="test_formal">).)*<span class="test_formal2">.*)$

          – Rob Rob
          Dec 30 '18 at 15:33













          @RobRob: That wasn't clear. I've completely rewrite the regex, it's now really simplifed.

          – Toto
          Dec 30 '18 at 16:23





          @RobRob: That wasn't clear. I've completely rewrite the regex, it's now really simplifed.

          – Toto
          Dec 30 '18 at 16:23


















          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%2f1388939%2fregex-select-all-lines-that-do-not-contain-some-particular-words-in-front-of-an%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

          "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

          Alcedinidae

          RAC Tourist Trophy