472,791 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how do I find position of character in string

I want to "look" through a comma delimited String and "take it apart" by
finding the comma's and then put each "set of characters" into seperate
strings - - - maybe an array, maybe seperate cells in a table -or-
whatever... Can anyone help me locate the commands (samples) that might do
this?
Actually, I want to read a file and use these comma seperated groups of data
to "load" a database and this comma seperated data is the individual data
columns of the database table that needs to be loaded...
Thanks,
Paul

Jul 21 '05 #1
9 25858
Sorry - I am using VB.Net and C#

"PaulThomas" wrote:
I want to "look" through a comma delimited String and "take it apart" by
finding the comma's and then put each "set of characters" into seperate
strings - - - maybe an array, maybe seperate cells in a table -or-
whatever... Can anyone help me locate the commands (samples) that might do
this?
Actually, I want to read a file and use these comma seperated groups of data
to "load" a database and this comma seperated data is the individual data
columns of the database table that needs to be loaded...
Thanks,
Paul

Jul 21 '05 #2
Use the string.split method

Jul 21 '05 #3
pSm
Paul,
Here's a sample in C# - make sure that your data doesn't have the
separator.

string str="A,B C,D,E";
char chSep=',';
string[] arrStr=str.Split(chSep);
for (int i=0;i<arrStr.Length ;i++)
Console.WriteLine(arrStr[i].ToString());

Console.ReadLine();

"Chris Dunaway" wrote:
Use the string.split method

Jul 21 '05 #4
Thanks,
I now have the String.Split working and trying to get the double quotes out
The data (splitting on comma) now produces an array of:
[0] "Name"
[1] ","
[2] "Info1"
[3] ","
[4] "Info2"
I am trying to use s[0].Replace(""","")
but it doesn't like the first string of the three double-quote I am trying
to remove
and it doesn't like the second string of double quotes ie: empty string
I am trying to remove the doublequotes in front and behind the string data
--or-- Am I just being DUMB looking at the data in the debugger and the
quotes only indicate string data and are not really there --no-- I am
putting each string in the array into a table cell (just to 'see' it) and the
quotes are there...
How can I specify the " character as the character to be replaced and How
can I specify an empty string ie: nothing to replace the " -or- I could
replace the " with a space and then use Trim to get rid of the leading and
trailing space...
Thanks again,
Paul
"pSm" wrote:
Paul,
Here's a sample in C# - make sure that your data doesn't have the
separator.

string str="A,B C,D,E";
char chSep=',';
string[] arrStr=str.Split(chSep);
for (int i=0;i<arrStr.Length ;i++)
Console.WriteLine(arrStr[i].ToString());

Console.ReadLine();

"Chris Dunaway" wrote:
Use the string.split method

Jul 21 '05 #5
pSm
Paul, if the source data doesn't have quotes, the string array would also not
contain quotes. So, no need of replacing anything.

"PaulThomas" wrote:
Thanks,
I now have the String.Split working and trying to get the double quotes out
The data (splitting on comma) now produces an array of:
[0] "Name"
[1] ","
[2] "Info1"
[3] ","
[4] "Info2"
I am trying to use s[0].Replace(""","")
but it doesn't like the first string of the three double-quote I am trying
to remove
and it doesn't like the second string of double quotes ie: empty string
I am trying to remove the doublequotes in front and behind the string data
--or-- Am I just being DUMB looking at the data in the debugger and the
quotes only indicate string data and are not really there --no-- I am
putting each string in the array into a table cell (just to 'see' it) and the
quotes are there...
How can I specify the " character as the character to be replaced and How
can I specify an empty string ie: nothing to replace the " -or- I could
replace the " with a space and then use Trim to get rid of the leading and
trailing space...
Thanks again,
Paul
"pSm" wrote:
Paul,
Here's a sample in C# - make sure that your data doesn't have the
separator.

string str="A,B C,D,E";
char chSep=',';
string[] arrStr=str.Split(chSep);
for (int i=0;i<arrStr.Length ;i++)
Console.WriteLine(arrStr[i].ToString());

Console.ReadLine();

"Chris Dunaway" wrote:
Use the string.split method

Jul 21 '05 #6
Paul,

There are more split methods in the System. namespace there is as well the
Regex Split and in the VisualBasic namespace as well a method Split.

You can always have a look if these fit you better.

Cor
Jul 21 '05 #7
The Regex.Split is working great - it's the double quotes I need to get
rid of because the data is enclosed in '' double quotes
Thanks again,
Paul
"Cor Ligthert" wrote:
Paul,

There are more split methods in the System. namespace there is as well the
Regex Split and in the VisualBasic namespace as well a method Split.

You can always have a look if these fit you better.

Cor

Jul 21 '05 #8
WROX publishes a handbook called "C# Text Manipulation" (VB too) that you
might consider adding as a reference.
I don't know if the series is still in print so you may have to go used via
Amazon.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
"PaulThomas" <Pa********@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com...
I want to "look" through a comma delimited String and "take it apart" by
finding the comma's and then put each "set of characters" into seperate
strings - - - maybe an array, maybe seperate cells in a table -or-
whatever... Can anyone help me locate the commands (samples) that might
do
this?
Actually, I want to read a file and use these comma seperated groups of
data
to "load" a database and this comma seperated data is the individual data
columns of the database table that needs to be loaded...
Thanks,
Paul

Jul 21 '05 #9
Use the string.Replace method or indexOf
that takes in double quotes

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
WROX publishes a handbook called "C# Text Manipulation" (VB too) that you
might consider adding as a reference.
I don't know if the series is still in print so you may have to go used via Amazon.

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
"PaulThomas" <Pa********@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com...
I want to "look" through a comma delimited String and "take it apart" by
finding the comma's and then put each "set of characters" into seperate
strings - - - maybe an array, maybe seperate cells in a table -or-
whatever... Can anyone help me locate the commands (samples) that might do
this?
Actually, I want to read a file and use these comma seperated groups of
data
to "load" a database and this comma seperated data is the individual data columns of the database table that needs to be loaded...
Thanks,
Paul


Aug 16 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Looks Like Trent | last post by:
Find a character in a string, at a specified position. How do you do this? Any help will be appreciated....
2
by: Faz | last post by:
I am trying to extract text before a certain character appears in a string. This character is the letter "C". Here is some sample data - the field is called REFERENCE_2: REFERENCE_2...
4
by: Neil Robbins | last post by:
Could anyone suggest a way in which I could find the position of the cursor within a textbox. I want to evaluate every keypress made within the textbox in order to validate it but in order to do...
6
by: KJ | last post by:
How can you look for a character in a certain position with VB.Net and if the string length is less than the position have it return and empty string instead of an error? Substring returnns an...
17
by: PaulThomas | last post by:
I want to "look" through a comma delimited String and "take it apart" by finding the comma's and then put each "set of characters" into seperate strings - - - maybe an array, maybe seperate cells...
3
by: magix | last post by:
Dear Guru, I have been thinking hard on how to token based on demiliter after certain position. Example, I have list of possible string below, and the the delimiter is "1" with the rules below...
3
by: magix | last post by:
How can I search for occurance of a character in certain position of a string I checked function strchr, but doesn't option to specify position. Thanks. Regards, Magix
7
kireytir
by: kireytir | last post by:
hi all, this is my code (in interrupt function) for finding character in string (data). Ekle_text.Text += data; string veri = Ekle_text.Text; int found = veri.IndexOf("x"); if (found !=...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.