473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How can I splitt the string

Plz help me.
How can I splitt the following string.
0A896>078957345:0A875>075456478:A5647>75647 (It depends on user how many row he selects.)
In this string first number is patient id while second is accession number.Now what I want to do that,separate all numbers.It should return patient id like (0A896,0A875,A5647) and accession number is like (078957345,075456478,75647).I want to display it in detail view.
Thank you!
Jan 10 '08 #1
5 1149
Shashi Sadasivan
1,435 Expert 1GB
Your first priority is to split the string by using the ':' (semicolon)

then for each string that is split, further split them using '>' (greater than)

if you have any issues while coding this or are still not able to find out the problem, Please paste the code if you can and we will be glad to point you in the right direction
Jan 10 '08 #2
user string.split("<") to array
here i give one example
string str = 123<23424<4545<54422
string[] final = new string[8];
final = str.split(("<").tochararray());
string one = final[0].tostring();
string two = final[1].tostring();

and so on

i think this will help you
Jan 10 '08 #3
Thank for ur reply but see what I want,
I am using ListView control to display data from database.It allows user to select the row.So now it depends on user,how many row he selects.for eg.if user selects two row & each row has patient id and Accesssion Number,then my string becomes 3433>0056455:634>667867 (where 3433 is patient id n 0056455 is Accesssion Number which is separated by ">" while two row are separated by ":")
First I will splitt string as (3433>0056455),(634>667867) ok.then I will splitt like
(3433),(0056455),(634),(667867).Now I want to make string like(3433),(634) and (0056455),(667867) ok.

BUT I am unable to make such string and cant write code for multiple selection of row(Becoz it depends on user how many row he selects.)
Plz reply someone.
Thank You!
Jan 11 '08 #4
r035198x
13,262 8TB
Thank for ur reply but see what I want,
I am using ListView control to display data from database.It allows user to select the row.So now it depends on user,how many row he selects.for eg.if user selects two row & each row has patient id and Accesssion Number,then my string becomes 3433>0056455:634>667867 (where 3433 is patient id n 0056455 is Accesssion Number which is separated by ">" while two row are separated by ":")
First I will splitt string as (3433>0056455),(634>667867) ok.then I will splitt like
(3433),(0056455),(634),(667867).Now I want to make string like(3433),(634) and (0056455),(667867) ok.

BUT I am unable to make such string and cant write code for multiple selection of row(Becoz it depends on user how many row he selects.)
Plz reply someone.
Thank You!
I have deleted your thread about this same problem. Please remember that double posting is gainst site rules.
As for your problem, I suggest you separate the activities. The first easy part is to split the string into separate strings containing the individual numbers. How to do this has already been explained to you.
You can store these numbers in arraylist e.t.c

The second part is the assignment of meaning to these numbers. i.e Mapping the numbers to the columns that were selected by the query. The order of the numbers in the arraylist should map to the order of the columns that were selected by the user.
Jan 11 '08 #5
CyberSoftHari
487 Expert 256MB
That simple Suvarna,
To write for multiple selection you have to use a “for loop”
Let
Expand|Select|Wrap|Line Numbers
  1. string str = "(3433),(0056455),(634),(667867)"
  2. string strArray ()= //Splite by coma and asigen to array
now your value is
Expand|Select|Wrap|Line Numbers
  1. strArray (0) = "(3433)"
  2. strArray (1) = "(0056455)"
  3. strArray (2) = "(634)"
  4. strArray (3) = "(667867)"
Now you got it.
You want to merge the index like strArray (0) and strArray (2) the strArray (1) and strArray (3)

Expand|Select|Wrap|Line Numbers
  1. For (int i=0; i<= n; i+=2)
  2. And
  3. For (int i=1; i<= n; i+=2)
Jan 11 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Krakatioison | last post by:
My sites navigation is like this: http://www.newsbackup.com/index.php?n=000000000040900000 , depending on the variable "n" (which is always a number), it will take me anywhere on the site......
5
by: Stu Cazzo | last post by:
I have the following: String myStringArray; String myString = "98 99 100"; I want to split up myString and put it into myStringArray. If I use this: myStringArray = myString.split(" "); it...
9
by: John F Dutcher | last post by:
I use code like the following to retrieve fields from a form: recd = recd.append(string.ljust(form.getfirst("lname",' '),15)) recd.append(string.ljust(form.getfirst("fname",' '),15)) etc.,...
9
by: Derek Hart | last post by:
I wish to execute code from a string. The string will have a function name, which will return a string: Dim a as string a = "MyFunctionName(param1, param2)" I have seen a ton of people...
10
by: Angus Leeming | last post by:
Hello, Could someone explain to me why the Standard conveners chose to typedef std::string rather than derive it from std::basic_string<char, ...>? The result of course is that it is...
37
by: Kevin C | last post by:
Quick Question: StringBuilder is obviously more efficient dealing with string concatenations than the old '+=' method... however, in dealing with relatively large string concatenations (ie,...
2
by: Andrew | last post by:
I have written two classes : a String Class based on the book " C++ in 21 days " and a GenericIpClass listed below : file GenericStringClass.h // Generic String class
2
by: s | last post by:
I'm getting compile errors on the following code: <code> #include <iostream> #include <fstream> #include <list> #include <string> using namespace std;
4
by: Heinz Zimmermann | last post by:
Hello, is it (in c#) possible, to splitt a large class into two or more files ? If yes, how can I do that ? Thanks Heinz
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.