Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / August 2005

Tip: Looking for answers? Try searching our database.

how do I find position of character in string

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PaulThomas - 17 Jun 2005 22:02 GMT
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
PaulThomas - 17 Jun 2005 22:03 GMT
Sorry - I am using VB.Net and C#

> 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
[quoted text clipped - 6 lines]
> Thanks,
> Paul
Chris Dunaway - 17 Jun 2005 22:54 GMT
Use the string.split method
pSm - 18 Jun 2005 05:30 GMT
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();

> Use the string.split method
PaulThomas - 18 Jun 2005 06:25 GMT
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

> Paul,
>    Here's a sample in C# - make sure that your data doesn't have the
[quoted text clipped - 9 lines]
>
> > Use the string.split method
pSm - 18 Jun 2005 06:39 GMT
Paul, if the source data doesn't have quotes, the string array would also not
contain quotes. So, no need of replacing anything.

> Thanks,
> I now have the  String.Split working and trying to get the double quotes out
[quoted text clipped - 33 lines]
> >
> > > Use the string.split method
Cor Ligthert - 18 Jun 2005 06:46 GMT
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
PaulThomas - 18 Jun 2005 14:36 GMT
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

> Paul,
>
[quoted text clipped - 4 lines]
>
> Cor
clintonG - 18 Jun 2005 16:16 GMT
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/

>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
[quoted text clipped - 8 lines]
> Thanks,
> Paul
Sajay Antony - 16 Aug 2005 12:03 GMT
Use the string.Replace method or indexOf
that takes in double quotes

> WROX publishes a handbook called "C# Text Manipulation" (VB too) that you
> might consider adding as a reference.
[quoted text clipped - 19 lines]
> > Thanks,
> > Paul

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.