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
size of pointers and architecture
Palindromic Pan digital Special Square wants you to reveal its Root
If a character has cast the Fly spell on themselves, can they "hand off" to the Levitate spell without interruption?
How do you earn the reader's trust?
Way of refund if scammed?
Why "strap-on" boosters, and how do other people say it?
Efficient Algorithms for Destroyed Document Reconstruction
Find this Unique UVC Palindrome ( ignoring signs and decimal) from Given Fractional Relationship
What is the required burn to keep a satellite at a Lagrangian point?
Illustrating that universal optimality is stronger than sphere packing
DeleteCases using two lists but with partial match?
Can diplomats be allowed on the flight deck of a commercial European airline?
Unary Enumeration
Shell builtin `printf` line limit?
Real Analysis: Proof of the equivalent definitions of the derivative.
Nunc est bibendum: gerund or gerundive?
How to become an Editorial board member?
Split into three!
How do I write real-world stories separate from my country of origin?
Ribbon Cable Cross Talk - Is there a fix after the fact?
What is the winged creature on the back of the Mordenkainen's Tome of Foes book?
Adobe Illustrator: How can I change the profile of a dashed stroke?
Why is unzipped file smaller than zipped file
How would a physicist explain this starship engine?
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
$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
pattern-matching filtering
$endgroup$
add a comment |
$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
pattern-matching filtering
$endgroup$
add a comment |
$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
pattern-matching filtering
$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
pattern-matching filtering
asked 3 hours ago
Sam BSam B
485
485
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
$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
$endgroup$
add a comment |
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
);
);
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%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
$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
$endgroup$
add a comment |
$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
$endgroup$
add a comment |
$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
$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
edited 26 mins ago
answered 3 hours ago
kglrkglr
193k10214434
193k10214434
add a comment |
add a comment |
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.
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%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
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