It's not a validation, it's an anchor, it avoids it matching other numbers. That's why the capture. If pygments was better designed it'll let you do semi-context-sensitive stuff like this, so you could say "numbers, but only if the follow a note name" -> durations
L On Fri, 25 Nov 2022, 17:52 Werner LEMBERG, <w...@gnu.org> wrote: > > > well -3 seems to be matching it, (say in a-3, I'm aware this is a > > fingering/articulation mark, not a duration). It appears to be an > > attempt to match a signed integer followed by zero or more dots. > > The thing is that the regular expressions match both LilyPond and > Scheme syntax. > > > It sucks that pygments regexes are context free, though. This > > should be using regex capturing and be more like > > `[a-g]((?:\d+|\\longa|\\breve)\.*)` or better yet be more like > > `[a-g]((?:2|4|8|16|32|64|128|\\longa|\\breve)\.*)`, it's not like a5 > > is a valid token... > > I don't think stuff like `ag` is a problem – it's not the job of > pygments to validate LilyPond input. > > > Werner >