Match patterns on list of Strings
Here is another one:
DeleteCases[data, _?(StringMatchQ[#, "A*"] &)]
I am not sure how to do this using DeleteCases
, but you can still use the Select
function:
Select[data, StringTake[#, 1] != "A" &]
which has the desired result.
Edit Actually, you can also use DeleteCases
like this:
DeleteCases[data, _?(StringTake[#, 1] == "A" &)]
Pick[data, StringMatchQ[#, "A*"] & /@ data, False]
(* => {"CD"} *)
EDIT: As noted in YvesKlett's comment, since StringMatchQ
threads over its first argument, we can also use
Pick[data, StringMatchQ[data, "A*"], False]
or
Pick[#, StringMatchQ[#, "A*"], False]&@data