473,799 Members | 3,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 26174
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.Spli t(chSep);
for (int i=0;i<arrStr.Le ngth ;i++)
Console.WriteLi ne(arrStr[i].ToString());

Console.ReadLin e();

"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.Spli t(chSep);
for (int i=0;i<arrStr.Le ngth ;i++)
Console.WriteLi ne(arrStr[i].ToString());

Console.ReadLin e();

"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.Spli t(chSep);
for (int i=0;i<arrStr.Le ngth ;i++)
Console.WriteLi ne(arrStr[i].ToString());

Console.ReadLin e();

"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********@dis cussions.micros oft.com> wrote in message
news:6B******** *************** ***********@mic rosoft.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*********@RE MOVETHISTEXTmet romilwaukee.com > wrote in message
news:uS******** ******@TK2MSFTN GP10.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********@dis cussions.micros oft.com> wrote in message
news:6B******** *************** ***********@mic rosoft.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
2380
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
35715
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 10299C17264 9841C17218 I want to extract 10299 for the first line and 9841 for the second
4
6260
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 this I need to know where the cursor is when the key is pressed. So far I can't see how I could do this. Any help would be very much appreciated, Neil R.
6
2139
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 error if the length is less than the position of the character you want. Ex. Dim x As String = 'ABCD'
17
582
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 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...
3
4067
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 - if the 5th character is "1", then it is delimiter elseif the 7th character is "1", then it is delimiter else this string is not a valid string
3
2525
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
3064
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 != -1) {
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10252
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10231
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.