# What would be a pattern for a general row of an identity matrix?

I know this is a novice question but I would like a pattern for a list containing zero or more zeros followed by exactly one 1, followed by zero or more zeros. Something like: {0___,1,0___}

But specifying that 0 must be zero.

• I think what you want is .. and ... that is Repeated and RepeatedNull rather than Blank and its friends. – Carlo Aug 8 '14 at 15:19
• Yes, thanks to Carlo and Micahal E2. I am using this to build a row reduction method without loops. – John McGee Aug 8 '14 at 16:30
• When using patterns, beware of the difference between 1 and 1. or 0 and 0.. Generally, you can also use /; and specify an arbitrary condition in patterns, e.g.row_ /; Count[row, 1] == 1 && Union[row] == {0, 1} (not necessarily the best solution for this particular problem). – Szabolcs Aug 8 '14 at 17:39

I believe you're looking for RepeatedNull
Count[IdentityMatrix[10], {0 ..., 1, 0 ...}]