Create variable using subset of servers

I have metrics for my servers stored in Graphite under a /data/ path. Some of these servers have a JVM, whose metrics are stored in a jvm subfolder, i.e. /data//jvm/
I want to create a dashboard variable that contains the names of the servers, but only those with JVM metrics. Is there any combination of the query and regex fields that will allow me to achieve this?
e.g. if I have a query of “data.*” I get all the servers, not just those with a JVM.

For the benefit of anyone who has the same problem, the new support for the Graphite expand() function in V8 allows me to solve this.

Graphite: Expand metric names for variables by ifrost · Pull Request #33694 · grafana/grafana · GitHub