Consider the following code:
{
'template-string-pattern': /`(?:\\[\s\S]|\${[^}]+}|[^\\`])*`/,
'a': 0,
'b': 1
};
{
'string' : /(`|')(?:\\.|(?!\1)[^\\\r\n])*\1/m,
'c': 0
};
Highlighted using Test Drive:

What's happening is quite simple:
template-string matches (?:\\[\s\S]|\${[^}]+}|[^\\ and /, 'a': 0 ....... 'string': /( (plus the grave accents).string matches 'template-string-pattern' and 'c'. The rest is blocked by template-string.regex breaks the matches of template-string and highlights the regexes.string gets a chance from regex to match and does so matching 'a'. But that's it, because oneshot=true.Btw: You can see this bug all over the place when you look at the Prism code with lots of language definitions.
Here is a minimal example showing the bug in action:
Language definition
I used aliases for styling.
Prism.languages['greedy-test'] = {
'a': {
pattern: /'[^'\r\n]*'/,
alias: 'comment'
},
'b': {
pattern: /"[^"\r\n]*"/,
greedy: true,
alias: 'string'
},
'c': {
pattern: /<[^>\r\n]*>/,
greedy: true,
alias: 'keyword'
}
}
Code:
<'> '' ''
<"> "" ""
(Each line is one example.)
Result:

Notes:
a and b is not significant. They just have to be before c.
Most helpful comment
Here is a minimal example showing the bug in action:
Language definition
I used aliases for styling.
Code:
(Each line is one example.)
Result:

Notes:
aandbis not significant. They just have to be beforec.