Click to See Complete Forum and Search --> : Parsing String .


prince
01-27-2005, 10:28 PM
I am trying to capture a String from an Application and parse it and the substring obtained is modofied and passed as input to another application after modification.

For Example consider the string below:
String S= " *ABC{ abc bcd cda abz};#{twtr adscs ascdf hsfwo};#
AS1{abc;abc1;abc2;abc3;....}#;
AS2{bcd1;bcd2;bcd3;bcd4;...}#;
AS3{acd1;acd2;bcd3;...};"

My problem is.

1) am parsing the string using String Tokenizer with a delimitatior as #. But it seperates AS1 AS2 As3 aswell. Which i need as combined input for passing to other application. I must get
AS1{abc;abc1;abc2;abc3;....}#;AS2{bcd1;bcd2;bcd3;bcd4;...}#;AS3{acd1;acd2;bcd3;...};" together which am not getting. Please suggest.

2) I need to pass this dynamically to the other application so am writing the same on a file but after writing it on file and reading it am getting something like this.

String Sin="AS1{abc; abc1; abc2; abc3;....};"
Please notice the white spaces which is not desired and cannot be passed.

Please advise/suggest for any alternatives or solutions.

Thanks.

Nadeem
02-10-2005, 08:17 AM
iam not sure of what exactly u r trying to do if u do need the AS1 AS2 AS3 together then see that the token u r getting has a substring of AS? whatever u need if so copy it to a single string instead of individual tokens then pass that string to wherever u want.

prince
02-13-2005, 10:38 PM
Hello Nadeem,

thanks for the reply, i could solve the problem using split() and subsequently writing and reading the file and modifying it after seperating them.

I appreciate and Thank you for your intrest and reply.

regards.