Sol in simple mode

I am trying to write a very generic editor, and wanted to highlight any known keywords, no context awareness required.

I created the following regex

    var commonAttributes = ["var", "val", "let", "if", "else", "export", "import", "return", "static", "fun", "function", "func", "class", "open", "new", "as", "where", "select", "delete", "add", "limit", "update", "insert"]
    let standalonePrefix = "(?<=[\\s]|^|[\\(,:])"
    let standaloneSuffix = "(?=[\\s\\?\\!,:\\)\\();]|$)"

and the following state.

          regex: new RegExp(standalonePrefix+"("+commonAttributes.join("|")+")"+standaloneSuffix, "i"),
          token: "keyword"

I understand that to match at line beginning , I would have to use sol: true, as ^ has no meaning in our context. But this causes problems for me.
without sol: true, writing

let leaflet let

will highlight all lets.
with sol: true,
only first let will match

let leaflet let

My desired outcome is that i get,

let leaflet let

How can I do so?

Start-of-line doesn’t really seem to be what you want. I think the best way to avoid matches inside words is to make sure you have another token (with lower precedence than the keyword-style token) that matches entire words. That’ll make sure no token is stared in the middle of a word.