java - Getting value of string inside some regular expression -


i have code this:

string s1 = "((${adapterkind=vmware, resourcekind=virtualmachine, metric=disk|usage_average}*${this, metric=summary|oversizedvmcount})+${this, metric=summary|poweredoffvmcount})"; //some code  want output inside  string[] s2 = {${adapterkind=vmware, resourcekind=virtualmachine, metric=disk|usage_average}, ${this, metric=summary|oversizedvmcount}, ${this, metric=summary|poweredoffvmcount}}; 

basically want values "${...}". how can achieve this?

string s1 = "((${adapterkind=vmware, resourcekind=virtualmachine, metric=disk|usage_average}*${this, metric=summary|oversizedvmcount})+${this, metric=summary|poweredoffvmcount})"; pattern p = pattern.compile("\\$\\{[^}]*\\}"); matcher m = p.matcher(s1); while(m.find())     //here have captured texts,      //you can put array/collection     system.out.println(m.group()); 

this output:

${adapterkind=vmware, resourcekind=virtualmachine, metric=disk|usage_average} ${this, metric=summary|oversizedvmcount} ${this, metric=summary|poweredoffvmcount} 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -