rmvprasad
asked on
String.split() function not working properly
I have a delimiter="*&?";
I have a string,each word is seperated by a delimiter and at the end of the string I have appended an integer(concerted it into string and appended). If I used String.Split(Delimiter) function each string seperated by the delimiter should be stored in an array. But the last string (which was a num converted to string) is still along with delimiter
I have a string,each word is seperated by a delimiter and at the end of the string I have appended an integer(concerted it into string and appended). If I used String.Split(Delimiter) function each string seperated by the delimiter should be stored in an array. But the last string (which was a num converted to string) is still along with delimiter
Please post the string and your code
ASKER
String str = "<Make>Computer General</Make>"
+"<Model>Wizbang 1900</Model>"
+"<Warranty>T</Warranty>"
+"<Maintenance>F</Maintena nce>";
String DELIMITER = ":$*";
int childIndex = 0;
String temp = String.valueOf(childIndex) ;;
treeString = tag.substring(leftAngleInd ex+1,right AngleIndex );
treeString = treeString + DELIMITER;
treeString = treeString + EMPTYSPACE;
treeString = treeString + temp;
String[] treeStringArr = treeString.split(DELIMITER );
+"<Model>Wizbang 1900</Model>"
+"<Warranty>T</Warranty>"
+"<Maintenance>F</Maintena
String DELIMITER = ":$*";
int childIndex = 0;
String temp = String.valueOf(childIndex)
treeString = tag.substring(leftAngleInd
treeString = treeString + DELIMITER;
treeString = treeString + EMPTYSPACE;
treeString = treeString + temp;
String[] treeStringArr = treeString.split(DELIMITER
Can you just post the value of treeString
u need to escape the charas in that regex
String[] treeStringArr = treeString.split("\\:\\$\\ *");
or better use a different delimiter
String DELIMITER = "___";
though the code you posted you don't actually need to split:
String[] treeStringArr = new String[] { tag.substring(leftAngleInd ex+1,right AngleIndex ), treeString + EMPTYSPACE + temp};
String[] treeStringArr = treeString.split("\\:\\$\\
or better use a different delimiter
String DELIMITER = "___";
though the code you posted you don't actually need to split:
String[] treeStringArr = new String[] { tag.substring(leftAngleInd
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
as 1-9 are non printable chars