Deleting certain elements of a list

This query is similar to a question I posted earlier.

Given

testList =
{{"a", "b 3", "cd", "ef 23"}, {"z 12", "y", "x"}, {"z", "y"}, {"a", "b3"}};


I would like to create a rule that would delete 1st level elements of testList that do not contain a string representation of a number. The result would be:

resultList = {{"a", "b 3", "cd", "ef 23"}, {"z 12", "y", "x"}, {"a", "b3"}};


Although I very much in favor of aardvark2012's answer using Pick, I would like to note that this can done with good old Table.

data = {{"a", "b 3", "cd", "ef 23"}, {"z 12", "y", "x"}, {"z", "y"}, {"a", "b3"}};
Table[If[Or @@ StringContainsQ[item, DigitCharacter], item, Nothing], {item, data}]


{{"a", "b 3", "cd", "ef 23"}, {"z 12", "y", "x"}, {"a", "b3"}}

One possibility:

Pick[#, Or @@@ StringContainsQ[DigitCharacter] /@ #] &@testList2


or

Select[testList2, Or @@ StringContainsQ[#, DigitCharacter] &]


If the OP really wants a Rule then anothe options is:

rule = Rule[
PatternTest[Blank[List],
Composition[
Not,
Apply[Or],
Map[StringContainsQ[DigitCharacter]]
]
]
, Nothing
]


Or

rule= _List?(Not@*Apply[Or]@*Map[StringContainsQ[DigitCharacter]]) -> Nothing


Then

testList /. rule
(* {{"a", "b 3", "cd", "ef 23"}, {"z 12", "y", "x"}, {"a", "b3"}} *)

(testList /. rule) == resultList
(* True *)

• Although admonished not to say thanks, I'll say thanks /@ aardvark2012, m_goldberg,rhermans :) Commented Sep 24, 2017 at 5:18