DeleteCases using two lists but with partial match?Pattern to match L, but not L[_]Using DeleteCases with...

Unary Enumeration

Can diplomats be allowed on the flight deck of a commercial European airline?

Why is 'additive' EQ more difficult to use than 'subtractive'?

Why is this python script running in background consuming 100 % CPU?

Why is this integration method not valid?

What defines a person who is circumcised "of the heart"?

If a character has cast the Fly spell on themselves, can they "hand off" to the Levitate spell without interruption?

What does it mean for something to be strictly less than epsilon for an arbitrary epsilon?

How to make Flex Markers appear in Logic Pro X?

How to become an Editorial board member?

Adobe Illustrator: How can I change the profile of a dashed stroke?

Efficient Algorithms for Destroyed Document Reconstruction

Why the work done is positive when bringing 2 opposite charges together?

Is there a word for pant sleeves?

Does science define life as "beginning at conception"?

Ribbon Cable Cross Talk - Is there a fix after the fact?

csname in newenviroment

Shell builtin `printf` line limit?

Can a UK national work as a paid shop assistant in the USA?

What pc resources are used when bruteforcing?

mmap: effect of other processes writing to a file previously mapped read-only

DeleteCases using two lists but with partial match?

Coloring lines in a graph the same color if they are the same length

(For training purposes) Are there any openings with rook pawns that are more effective than others (and if so, what are they)?



DeleteCases using two lists but with partial match?


Pattern to match L, but not L[_]Using DeleteCases with multiple AstronomicalData propertiesUsing the string Match with options!Filtering lists by partial matchesProblem with DeleteCasesDeleteCases and Pattern Matching With NumberQUsing DeleteCases to match a string patternSelecting elements using two listsusing DeleteCases to delete vectors with particular index as 0Using DeleteCases with a defined function with two arguments as a pattern













3












$begingroup$


I searched and tried different solutions on SE but nothing worked.



I have two lists and would like to remove items from list1 that have a PARTIAL match with items in list2. I'm new to this.



I tried this but it didn't filter anything out



Select[List1, ! MemberQ[List2, #] &]


I also tried with DeleteCases and StringMatchQ but only got various errors. I tried a few solutions from SE but none worked for my specific case.



list1 = {"http://www.domain.com/research", "http://www.domain.com/signup", "tel:5559986644", "mailto:info@domain.com"}



list2 = {"tel:", "mailto:"}



results = {"http://www.domain.com/research", "http://www.domain.com/signup"}



Thank you in advance










share|improve this question









$endgroup$

















    3












    $begingroup$


    I searched and tried different solutions on SE but nothing worked.



    I have two lists and would like to remove items from list1 that have a PARTIAL match with items in list2. I'm new to this.



    I tried this but it didn't filter anything out



    Select[List1, ! MemberQ[List2, #] &]


    I also tried with DeleteCases and StringMatchQ but only got various errors. I tried a few solutions from SE but none worked for my specific case.



    list1 = {"http://www.domain.com/research", "http://www.domain.com/signup", "tel:5559986644", "mailto:info@domain.com"}



    list2 = {"tel:", "mailto:"}



    results = {"http://www.domain.com/research", "http://www.domain.com/signup"}



    Thank you in advance










    share|improve this question









    $endgroup$















      3












      3








      3





      $begingroup$


      I searched and tried different solutions on SE but nothing worked.



      I have two lists and would like to remove items from list1 that have a PARTIAL match with items in list2. I'm new to this.



      I tried this but it didn't filter anything out



      Select[List1, ! MemberQ[List2, #] &]


      I also tried with DeleteCases and StringMatchQ but only got various errors. I tried a few solutions from SE but none worked for my specific case.



      list1 = {"http://www.domain.com/research", "http://www.domain.com/signup", "tel:5559986644", "mailto:info@domain.com"}



      list2 = {"tel:", "mailto:"}



      results = {"http://www.domain.com/research", "http://www.domain.com/signup"}



      Thank you in advance










      share|improve this question









      $endgroup$




      I searched and tried different solutions on SE but nothing worked.



      I have two lists and would like to remove items from list1 that have a PARTIAL match with items in list2. I'm new to this.



      I tried this but it didn't filter anything out



      Select[List1, ! MemberQ[List2, #] &]


      I also tried with DeleteCases and StringMatchQ but only got various errors. I tried a few solutions from SE but none worked for my specific case.



      list1 = {"http://www.domain.com/research", "http://www.domain.com/signup", "tel:5559986644", "mailto:info@domain.com"}



      list2 = {"tel:", "mailto:"}



      results = {"http://www.domain.com/research", "http://www.domain.com/signup"}



      Thank you in advance







      pattern-matching filtering






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      Sam BSam B

      485




      485






















          1 Answer
          1






          active

          oldest

          votes


















          3












          $begingroup$

          Cases[_?(Not@*StringStartsQ[Alternatives @@ list2])]@list1
          Cases[Except[_?(StringStartsQ[Alternatives@@list2])]]@list1
          DeleteCases[_?(StringStartsQ[Alternatives @@ list2])]@list1
          Select[list1, Not @* StringStartsQ[Alternatives @@ list2]]


          all give




          {"http://www.domain.com/research", "http://www.domain.com/signup"}




          You can also use the pattern _?(StringMatchQ[#, Alternatives @@ list2 ~~ "*"]&), e.g.,



          DeleteCases[list1, _?(StringMatchQ[#,Alternatives @@ list2~~"*"]&)]



          same result







          share|improve this answer











          $endgroup$














            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "387"
            };
            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: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            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%2fmathematica.stackexchange.com%2fquestions%2f198685%2fdeletecases-using-two-lists-but-with-partial-match%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












            $begingroup$

            Cases[_?(Not@*StringStartsQ[Alternatives @@ list2])]@list1
            Cases[Except[_?(StringStartsQ[Alternatives@@list2])]]@list1
            DeleteCases[_?(StringStartsQ[Alternatives @@ list2])]@list1
            Select[list1, Not @* StringStartsQ[Alternatives @@ list2]]


            all give




            {"http://www.domain.com/research", "http://www.domain.com/signup"}




            You can also use the pattern _?(StringMatchQ[#, Alternatives @@ list2 ~~ "*"]&), e.g.,



            DeleteCases[list1, _?(StringMatchQ[#,Alternatives @@ list2~~"*"]&)]



            same result







            share|improve this answer











            $endgroup$


















              3












              $begingroup$

              Cases[_?(Not@*StringStartsQ[Alternatives @@ list2])]@list1
              Cases[Except[_?(StringStartsQ[Alternatives@@list2])]]@list1
              DeleteCases[_?(StringStartsQ[Alternatives @@ list2])]@list1
              Select[list1, Not @* StringStartsQ[Alternatives @@ list2]]


              all give




              {"http://www.domain.com/research", "http://www.domain.com/signup"}




              You can also use the pattern _?(StringMatchQ[#, Alternatives @@ list2 ~~ "*"]&), e.g.,



              DeleteCases[list1, _?(StringMatchQ[#,Alternatives @@ list2~~"*"]&)]



              same result







              share|improve this answer











              $endgroup$
















                3












                3








                3





                $begingroup$

                Cases[_?(Not@*StringStartsQ[Alternatives @@ list2])]@list1
                Cases[Except[_?(StringStartsQ[Alternatives@@list2])]]@list1
                DeleteCases[_?(StringStartsQ[Alternatives @@ list2])]@list1
                Select[list1, Not @* StringStartsQ[Alternatives @@ list2]]


                all give




                {"http://www.domain.com/research", "http://www.domain.com/signup"}




                You can also use the pattern _?(StringMatchQ[#, Alternatives @@ list2 ~~ "*"]&), e.g.,



                DeleteCases[list1, _?(StringMatchQ[#,Alternatives @@ list2~~"*"]&)]



                same result







                share|improve this answer











                $endgroup$



                Cases[_?(Not@*StringStartsQ[Alternatives @@ list2])]@list1
                Cases[Except[_?(StringStartsQ[Alternatives@@list2])]]@list1
                DeleteCases[_?(StringStartsQ[Alternatives @@ list2])]@list1
                Select[list1, Not @* StringStartsQ[Alternatives @@ list2]]


                all give




                {"http://www.domain.com/research", "http://www.domain.com/signup"}




                You can also use the pattern _?(StringMatchQ[#, Alternatives @@ list2 ~~ "*"]&), e.g.,



                DeleteCases[list1, _?(StringMatchQ[#,Alternatives @@ list2~~"*"]&)]



                same result








                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 20 mins ago

























                answered 2 hours ago









                kglrkglr

                193k10214434




                193k10214434






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Mathematica Stack Exchange!


                    • 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.


                    Use MathJax to format equations. MathJax reference.


                    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%2fmathematica.stackexchange.com%2fquestions%2f198685%2fdeletecases-using-two-lists-but-with-partial-match%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

                    Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

                    Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

                    Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...