# Pattern match Shortest BlankNullSequence in SequencePosition

Apologies if this has an answer somewhere but I can't find it.

From the examples for SequencePosition we are shown that

SequencePosition[{a, b, b, a, b, b, b}, {Repeated[b]}]


{{2, 3}, {3, 3}, {5, 7}, {6, 7}, {7, 7}}

If I change the pattern:

SequencePosition[{a, b, b, a, b, b, b}, {b, ___, b}]


{{2, 7}, {3, 7}, {5, 7}, {6, 7}}

Now I want to match the shortest lengths of blank null sequences, so I guess my desired outputs is {{2,3}, {3,5}, {5,6}, {6,7}. But Shortest doesn't seem to change anything:

SequencePosition[{a, b, b, a, b, b, b}, {b, Shortest[___], b}]


{{2, 7}, {3, 7}, {5, 7}, {6, 7}}

Where am I going wrong?

• Try SequencePosition[{a, b, b, a, b, b, b}, {b, Except[b] ..., b}].
– Kuba
May 10, 2016 at 11:10
• I suppose this is the same issue, yet I'm not sure: mathematica.stackexchange.com/q/72283/5478
– Kuba
May 10, 2016 at 11:11
• That's strange: looks like Shortest is simply ignored! The expected behavior should be as in SequencePosition[{a, b, c, d}, {Shortest[__]}] and SequencePosition[{a, b, c, d}, {__}]. I suspect a bug. May 10, 2016 at 12:22
• @Kuba That thread is about pattern matching in strings (implemented via PCRE), this question is about matching of usual patterns. So these questions are completely independent. May 10, 2016 at 12:27
• @AlexeyPopkov not entirely. There are no RegExps on OPs side there. They will be after translation from MMA patterns, so it is about Shortest too. Yet I won't insist, I'm not an expert in pattern matching.
– Kuba
May 10, 2016 at 12:36