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 / CLR / November 2005

Tip: Looking for answers? Try searching our database.

dot net functions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wendy Elizabeth - 03 Nov 2005 04:56 GMT
I am working with visual basic.net 1.1. I need to parse out data in a string
that is space delimited. The number of spaces between each data item in the
string can change. (I have no control over how many spaces are between each
item in the string since I am getting the data from a mainframe system over
the internet.)
I know that if I used the string function called split, I can split the
items in the string into items in an array. However, this is assuming the
delimiter is exactly the same. In this case, the number of spaces can change.
 Thus I am looking for a solution to this parsing problem. I do not care if
I used the split string function. I would just like a solution  that works.
 Thanks!
Scott M. - 03 Nov 2005 05:03 GMT
Just use split and then loop through the resulting array only paying
attention to array elements who's legnth is greater than zero.

>I am working with visual basic.net 1.1. I need to parse out data in a
>string
[quoted text clipped - 14 lines]
> works.
>  Thanks!
Sherif El-Metainy - 03 Nov 2005 16:51 GMT
Hello,

Here is how to achieve it (using c# syntax). It should be easy to convert it
to VB syntax

System.Text.RegularExpressions.Regex.Split(yourInputString, @"\s+");

check the regex class and regular expressions documentation for more info.

best regards,
Sherif

>I am working with visual basic.net 1.1. I need to parse out data in a
>string
[quoted text clipped - 14 lines]
> works.
>  Thanks!
David Farr - 03 Nov 2005 17:10 GMT
Better yet, use Regex to reduce all multiple spaces in the source string to
single, then use split:-
(using System.Text.RegularExpressions;)

string result = SourceString;

while(Regex.IsMatch(result,"  ") // double space
{
   result = Regex.Replace(result, "  ", " ");  // replace double with
single
}

Voila!

Dave

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



©2008 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.