I have a text file that appears to be delimited by multiple spaces. The
split function will only work with one space if I am correct. Is there some
way to split this file into an array without getting the extra spaces? 5 22934
Hi Christine!
if understood you're needs correctly, i suggest you to use
System.Text.Reg ex's Split() function instead of the String's one. It
supports a String parameter.
--
Best Regards
Yanick
"Christine" <Ch*******@disc ussions.microso ft.com> a écrit dans le message de
news:9B******** *************** ***********@mic rosoft.com... I have a text file that appears to be delimited by multiple spaces. The split function will only work with one space if I am correct. Is there
some way to split this file into an array without getting the extra spaces?
On Tue, 21 Dec 2004 12:07:02 -0800, Christine wrote: I have a text file that appears to be delimited by multiple spaces. The split function will only work with one space if I am correct. Is there some way to split this file into an array without getting the extra spaces?
Use the Regex (System.Text.Re gularExpression s.Regex) split instead as it
allows pattern matching rather than single character or specific string
matching.
Regex r = new Regex(" +");
string [] splitString = r.Split(stringW ithMultipleSpac es);
--
Tom Porterfield
Okay that helps with the spaces, but now I have a problem of a carriage
return at the end of each line that Regex doesn't take care of. Is there
some way to take care of this as well as the multiple spaces? Thanks so much
for the help!
"Tom Porterfield" wrote: On Tue, 21 Dec 2004 12:07:02 -0800, Christine wrote:
I have a text file that appears to be delimited by multiple spaces. The split function will only work with one space if I am correct. Is there some way to split this file into an array without getting the extra spaces?
Use the Regex (System.Text.Re gularExpression s.Regex) split instead as it allows pattern matching rather than single character or specific string matching.
Regex r = new Regex(" +"); string [] splitString = r.Split(stringW ithMultipleSpac es); -- Tom Porterfield
On Wed, 22 Dec 2004 06:45:05 -0800, Christine wrote: Okay that helps with the spaces, but now I have a problem of a carriage return at the end of each line that Regex doesn't take care of. Is there some way to take care of this as well as the multiple spaces? Thanks so much for the help!
You have several options. You could use the System.String.R eplace method
to replace the carriage return with an empty string, or you could use
System.String.T rimEnd - Ex:
string newString =
stringWithCarri ageReturn.TrimE nd(new char[]{'\r','\n',' '});
Note that the above will also trim any trailing spaces.
--
Tom Porterfield
Thank you so much, that was very helpful!
"Tom Porterfield" wrote: On Wed, 22 Dec 2004 06:45:05 -0800, Christine wrote:
Okay that helps with the spaces, but now I have a problem of a carriage return at the end of each line that Regex doesn't take care of. Is there some way to take care of this as well as the multiple spaces? Thanks so much for the help!
You have several options. You could use the System.String.R eplace method to replace the carriage return with an empty string, or you could use System.String.T rimEnd - Ex:
string newString = stringWithCarri ageReturn.TrimE nd(new char[]{'\r','\n',' '});
Note that the above will also trim any trailing spaces. -- Tom Porterfield This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: amitavabardhan |
last post by:
How Can I extract multiple tiff images into single images through asp
programming?
Is there any free dll's that I can use in ASP to split multiple tiffs into
single tiffs?
Any suggestion regarding this issue will be highly appreciated.....
|
by: Mindy Geac |
last post by:
Is it possible to delete special caracters from a string and multiple
spaces?
When the input is : "a&*bbb cc/c d!d"
I want the result : "abbb ccc dd"
thnx.
MJ
<?php
|
by: Anonieko Ramos |
last post by:
>
>
>
How to display multiple spaces in a dropdownlist
webform1.aspx
<asp:DropDownList id="DropDownList1"
runat="server"></asp:DropDownList>
|
by: Vikram |
last post by:
I have a label control whose text is having multile spaces "Name
:" but when this is rendered as html in an aspx page it only shows single
space. How to render with multiple spaces.
|
by: Joe Cool |
last post by:
I need to map several columns of data from one database to another
where the data contains multiple spaces (once occurance of a variable
number or spaces) that I need to replace with a single space. What
would be the most efficient way to do this? I am using SQL2K. I was
thinking a function since I know of no single Transact-SQL command
that can accomplish this task.
| |
by: cyberdrugs |
last post by:
Hi guys 'n gals,
I have a string which contains multiple spaces, and I would like to convert the multiple spaces into single spaces.
Example Input:
the quick brown fox jumps over the lazy dog
Example Output:
the quick brown fox jumps over the lazy dog
|
by: polturgiest |
last post by:
hie all
i got a form
<form name="TEST" method=POST action="test.php">
<input type="text" name="MyInput">
<input type="submit" name="ACTION" value="SAVE">
|
by: chris f |
last post by:
I'm dynamically populating a Table control in ASP.NET 2. Each row has 4
columns but column #3 needs to be split into 3 rows and column #4 needs to
be split into 4 rows. Each of these cells contains just text.
Can someone help me out? I can split one cell using the TableCell's RowSpan
property but I'm struggling with splitting 2 cells.
|
by: bstjean |
last post by:
Hi everyone,
I am trying to find an efficient way to perform a special query. Let
me explain what I want.
Let's say we are looking for all description that match "this is the
target". In fact, I want to find records that match those 4 words in
this sequence disregarding the number of spaces (I mean spaces, tabs,
Cr, Lf, etc) between them.
|
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...
|
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,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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,...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |