2017-07-12 3 views

Répondre

1

Si votre chaîne de requête doit avoir exactement le même format, cela peut fonctionner.

str = "15-min-sum:rate:proc.stat.cpu{host=foo,type=idle}" 
print(str[str.rfind(":")+1 : str.find("{")]) 
0

Le groupe 2 et le groupe 3 de ^(\w\W*)*:(.*){(.*)}$ capturent respectivement proc.stat.cpu et les options.

0
https://regex101.com/r/4aIVLr/4 

15-min-somme: Taux: proc.stat.cpu {host = foo, type = inactif}

(?![\w-]*:)([\w\.]*)({.*}) 
creates two group 

proc.stat.cpu

{host = foo, type = idle}