Quantcast
Viewing all articles
Browse latest Browse all 186

Removing all sublists containing any arbitrary string as one or more of its list component

so, basically I have a list of sublists of varying length. For example,

list={{#,a,b,c,d},{#,e,f,g},{#,h,1},{#,2},{#},{#,k,l,m,n,o},{#,a,b,1,2},{1,2},{2,3},{3,4},{4,5}}

And I would like to end up with

listFiltered={{1,2},{2,3},{3,4},{4,5}}

So, what I would like to filter out is all the sublist containing any string.Now, instead of filtering for any sublist containing any string, I also know that each sublist that I want to filter out has the "#" character as its first sublist element.

This is then the repeating pattern, a "#" character as the first element of every sublist of arbitrary length, that contains a string somewhere, and therefore should be removed from the main list.

How should I go about achieving this? I have tried a number of things with DeleteCases and StringMatchQ but couldn't really get the syntax right.Thank you very much in advance!


Viewing all articles
Browse latest Browse all 186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>