# Select nested lists based on string pattern

I would like to select nested lists out of a master list based on certain string pattern as in the following example:

lis = {{a, b, c, d}, {xy, y, z, w}, {e, f, g, h}, {xz, f, g, h}};


I would like to create a list with all nested lists starting with x* in the fist position.

I tried the following functions:

Cases[lis, {q_, r__} /; StringMatchQ[q, "x*"] -> {q, r}]


or

Select[lis2, First[#] == x &]


Both do not work.

Does anyone can give me a hint?

Just get the symbol's name and match for that:

Cases[lis, {q_, r__} /; StringMatchQ[SymbolName[q], "x*"] -> {q, r}]
(* {{xy, y, z, w}, {xz, f, g, h}} *)


or using Select:

Select[lis, First@Characters[SymbolName[First@#]] == "x" &]

• Thanks, but it still does not work. Obviously my question was incorrect. I have a list of all stock indicies available in Mathematica. Some of these entries are obviously no indices Therefore I would like to select only the "complete" entries using "^*" as identifier . The list looks as follows: lis = {{"^DYI", "Dynamic Market Intellidex Index", "AMEX", "Dynamic Market \ Intellidex Index"}, {FinancialData["^EBT-TC", "Symbol"], {"^EEV-NV", "Ishares Msci Emerging Markets I", "AMEX", \ "Ishares Msci Emerging Markets I"}} Any idea? Thanks Phadreus – Phadreus Mar 9 '15 at 12:13
• Thanks, I solved the problem. I missed the String definition of the variable q_String. Here my final function: Cases[lis, {q_String, r__} /; StringMatchQ[q, "^*"] -> {q, r}] – Phadreus Mar 9 '15 at 13:49
• At least I pointed you in the right direction. :) – Jinxed Mar 9 '15 at 14:25
• @Phadreus: And, I hope, my answer is actually an answer to your original question. If so, would you mind marking it as such? – Jinxed Mar 9 '15 at 14:26