Again, I have a list like this:
list={0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, \
0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, \
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}
I want to search for the pattern: {1,0,0} and mark all the numbers matching this sequence in Red with the Style option. I tried to use Cases to help me out, which does not work. Checked the help a few times, but no idea so far :/
Cases[list, {1,0,0}]








list //. {b__, PatternSequence[1, 0, 0], a__} -> {b, Sequence @@ (Style[#, Red] & /@ {1, 0, 0}), a}? – b.gates.you.know.what Aug 24 '14 at 21:31a___andb___- BlankNullSequence - to include boundary cases for more general situations. – Vitaliy Kaurov Aug 24 '14 at 21:36PatternSequence @@ patternwill strip off theListhead i.e.{}, of that pattern and make the pattern the argument ofPatternSequence. Also, make sure to change the replacement to(Style[#, Red] & /@ patternas well. – seismatica Aug 24 '14 at 22:16