Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i get a line of string from a web service that looks like this
INFO(        )NAME: suresh Kinta     Section: 2D Age: 10      Phone: 7777777 Address: ID(        )(        )Grades(        )Math: B     Physics: B History: B Logic:B


i need to cut the strings in a way that it would look like this
INFO
NAME: suresh      Section: 2D
Age: 10      Phone: 7777777
Address: ID

Grades
Math: B     Physics: B
History: B       Logic:B


so far i was able to do this
INFO
NAME: suresh Kinta     Section: 2D Age: 10      Phone: 7777777 Address: ID

Grades
Math: B     Physics: B History: B Logic:B


i need help on finding a pattern so that i could split the remaining strings so that the age and phone would be on a new line as well as the address and the subjects history and Logic too.
I cannot change the way the string is sent by the web service..
Posted
Comments
Maciej Los 20-Apr-15 2:00am    
Show us what have you done till now (your code). Use "Improve question" widget.

1 solution

have you paste the exact same string as you are getting from webservice because their should be some uniqueness between tags. like NAME:suresh kinta and Section:2D their are 4 spaces and after section and age their is only one space. Otherwise you would have used simple Replace method to solve it.
If the number of spaces are unique after each tag than you can do it like this. suppose number of spaces after each tag is four. so i will replace those four spaces with line break.

C#
string a = what Ever You Getting From WebService;
a = a.Replace("    ","<br>");
Response.Write(a);</br>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900