How can i show this? substring?split? ...
but it's maybe dynamic !!!
开发者_运维知识库String str = "SET ENCALSUP=NOENCR&GSMV2,MAXNCELL=16,TDTMWIND=5,MAXLAPDMN=5,EENHDTMSUP=DISABLED,T3197=4,PAGCOORCLB=DISABLED,DGRSTRGYBCNT=DISABLED,PAGQOVLIND=0;";
this output (EENHDTMSUP=DISABLED):
just this
DISABLED
Thanks ...
Your question isn't very clear. Do you just need to know the value of "EENHDMSUP"?
If so, something like:
int start = myString.indexOf("EENHDTMSUP=");
String substr = myString.subString(start,myString.indexOf(',',start);
System.out.println(substr);
Would probably work.
Is this what you're looking for?
StringTokenizer tokenizer = new StringTokenizer(str.substring(4),",");
while(tokenizer.hasMoreTokens()){
System.out.println(tokenizer.nextToken());
}
Not sure what you meant by "but it's maybe dynamic." But if the string always follows that format and "EENHDTMSUP=DISABLED" stays at that same index in the string, then you can use:
String output = str.Split(',')[4];
Why don't you try?
String[] strings = str.split(",");
for (String s:strings) {
if (s.toLowerCase().startsWith("set ")) {
s = s.substring("set ".length());
}
System.out.println(s);
}
Using regular expressions of course ;)
精彩评论