After a bit of googling I have learned that I can do the following
Delete[domains, Position[domains, "aa.com"]]
However, I think this only works if the element exactly matches the pattern, so my revised question is how would I search for a substring within an element. In effect I want to do something like this
Hi Michael,
_?(StringContainsQ[#, “aa.com”] &)
Seems to do exactly what I need. However, I am not entirely clear how it works. The help seems to suggest that
_?() means match any expression and then return true if the expression in the parenthesis evaluates to true. Have I understood that correctly?
Hi Andy,
please have look at “PatternTest” in the documentation. DeleteCases requires a pattern as a second argument, and _?test is the pattern that matches everything provided the condition “test” evaluates to True. The parenthesis are required to control the sequence of evaluation due to the high precedence of the ? operator (also described in the docu).