Regex for Sonarqube Issue Key field?

Must-share information (formatted with Markdown):

  • Sonarqube 7.9.1
  • Trying to understand what valid characters are in Issue’s Key field so I can write a regex for it
  • I think this works but I had to add “-” recently because I didn’t notice some keys included a dash: ([\w_-]+)

Wanted to confirm this is correct and these are the only valid characters.


Could you give a little more context on this? What specific rule and language are we talking about?


Not sure it matters which language?
It’s the REST API for Sonarqube. You download a list of issues… each issue has an Issue Key…


Ah! Okay! Context helps.

Have you tried looking at the Response Example in the onboard web service documentation? (You’ll find a link in your page footer.) This looks like a GUID to me, i.e. automatically generated, so we probably can’t easily give you a comprehensive character class.


“key”: “issue”,
“description”: “Issue key”,
“required”: true,
“internal”: false,
“exampleValue”: “AU-Tpxb–iU5OvuD2FLy”

Notice that it didn’t say underscores are allowed but they apparently are from my testing.

I was hoping you’d know since you have the source code and Sonarqube is generating these keys :slight_smile:


I’m not familiar with the code, but I can almost guarantee you that we’re using a standard function or library for GUID generation.


a standard guid looks like this:

So Sonarqube’s issue key is definitely not standard. It has underscores in it for one…and there are no sections like a standard UUID FYI.