Sathish David Kumar N
asked on
how to split the string
Hi i have ah string like this
String s = add(add(12,5),5)
I want to split this first i want to do inside add then come to out side
String s = add(add(12,5),5)
I want to split this first i want to do inside add then come to out side
Why you mention split string ? If using split() to split string with delimiter
of "-",for example, the code will be this
Could you write it more and in detail
Duncan
of "-",for example, the code will be this
String string = "004-034556";
String[] parts = string.split("-");
String part1 = parts[0]; // 004
String part2 = parts[1]; // 0
Could you write it more and in detail
Duncan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Praser?? Can you give some example?
ASKER
Chj can you tell how implement in my example string
Sorry - no. I have no experience with it personally
If you want
add(add(12,5),5) to change to No((no(12)+no(5))+no(5))
add(add(12,5),5) to change to No((no(12)+no(5))+no(5))
import java.util.regex.*;
public class Test {
public static void main(String args[]){
String s = "add(add(12,5),5)";
Pattern p = Pattern.compile("-?\\d+");
Matcher m = p.matcher(s);
StringBuilder sb = new StringBuilder("No((");
while (m.find()) {
sb.append("no(" + m.group() + ")+");
}
sb.deleteCharAt(sb.length() - 1);
sb.append(")");
System.out.print(sb.toString());
}
}
I suspect your example is a sample representation of some real data that probably has more than one variation. Perhaps you can provide some different samples and, most importantly, an explicit explanation of the criteria to employ to produce your desired results.
ASKER
No((no(12)+no(5))+no(5)) how do this