Hello All:
A pretty frustrating question to ask! I use the string [] something
= stringx.split (delimiter.toch ararray()) mathod to delimit a long
string by space! So supposely
if the stringx is :
" something something1 something2 " I should get string [0] =
something, string[1] = something1...et c
However question comes what happens if the string looks like this
" something something1 something 2"
instead of string [0] = something, string[1] = something1...
I get string [0] = something string[1] = "" string[2] =
""........strin g[11] = something1....e tc
In excel there is a function in text delimiter to treat all similar
delimiter as one. I just wondering how to do that in C#?
Thank You For your reply! 2 2691
"pengb" <pe******@yahoo .comwrote in news:1161272163 .227933.172150
@e3g2000cwe.goo glegroups.com:
Hello All:
A pretty frustrating question to ask! I use the string [] something
= stringx.split (delimiter.toch ararray()) mathod to delimit a long
string by space! So supposely
if the stringx is :
" something something1 something2 " I should get string [0] =
something, string[1] = something1...et c
However question comes what happens if the string looks like this
" something something1 something 2"
instead of string [0] = something, string[1] = something1...
I get string [0] = something string[1] = "" string[2] =
""........strin g[11] = something1....e tc
In excel there is a function in text delimiter to treat all similar
delimiter as one. I just wondering how to do that in C#?
You can use RegularExpressi ons to do this.... pretty simple really:
string s = "something something somethingelse";
string[] ss = System.Text.Reg ularExpressions .Regex.Split(s, @"\s+");
-mdb
pengb wrote:
Hello All:
A pretty frustrating question to ask! I use the string [] something
= stringx.split (delimiter.toch ararray()) mathod to delimit a long
string by space! So supposely
if the stringx is :
" something something1 something2 " I should get string [0] =
something, string[1] = something1...et c
However question comes what happens if the string looks like this
" something something1 something 2"
instead of string [0] = something, string[1] = something1...
I get string [0] = something string[1] = "" string[2] =
""........strin g[11] = something1....e tc
In excel there is a function in text delimiter to treat all similar
delimiter as one. I just wondering how to do that in C#?
Checking the docs, I see that the string.split method has several
overloads. One of them takes a StringSplitOpti ons enum:
string[] sa = s.Split(new char[] { ' ' },
StringSplitOpti ons.RemoveEmpty Entries); This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ShyGuy |
last post by:
I have a table with 4 fields. Three are used for criteria.
I can get the DLookup to work with 1 criteria with the following but
can't get it to work with 2 or three.
NumofAppts = DLookup("", "LookUpAppts", "
= " & Forms!!NumofPeople)
Can someone tell me how to add multiple criteria? I tried "And" but
it doesn't seem to work.
|
by: Mark Fox |
last post by:
Hello,
The string.Split method is very useful for splitting
strings that use a single character as a delimiter. i.e.:
string str = "First;Second;Third";
string strArray = str.Split(new char {';'});
But I am having trouble getting the Split method to split
|
by: Graham |
last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and wizards.
But, I have found that trying to do something "outside the norm" adds a rather large level of complexity and/or data replication.
Background
I have been commissioned to create a web-based application for a client. It has a formsaunthentication...
|
by: simonc |
last post by:
One of the things that drives me mad about vb.net is
spending time trying to make a program do something then
finding that there's already an inbuild procedure that
does exactly the same thing.
So before I begin on this can anyone tell me if there is
already a routine to do this:
I am dividing up a delimited textstring using
string.split. The delimiter character is a space, but
|
by: Craig Buchanan |
last post by:
Is there a way to combine these two Replace into a single line?
Regex.Replace(Subject, "\&", "&")
Regex.Replace(Subject, "\'", "'")
Perhaps Regex.Replace(Subject, "{\&|\'}", "{&|'}")
Thanks,
Craig
| |
by: TCB |
last post by:
How can I separate multiple email addresses entered in a single textbox, the
email addresses are separated by (,) or (;)
Thanks
|
by: Geometer |
last post by:
Hello, and good whatever daytime is at your place..
please can somebody tell me, what the standard behavior of strtok shall be,
if it encounters two or more consecutive delimiters like in
(checks omitted)
char tst = "this\nis\n\nan\nempty\n\n\nline";
^^^^ ^^^^^^
char *tok = strtok(tst, "\n");
|
by: vang |
last post by:
How do I find out which delimiter if found/used when splitting a
string with multiple delimiters are defined in a char array?
Example:
dim i as integer
dim returnText as string
dim InputText as string = "apples/orange\banana"
dim delim as char = {"\", "/", "$")
|
by: Peted |
last post by:
hello, i have a app.config file like so
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="rdbUser1Cpu1" value="Cpu1,test"/>
</appSettings>
</configuration>
|
by: micarl |
last post by:
How would i print a report based on criteria selected from several
Combo Boxes as well as multiple Multi Select List Boxes, that are
located on the same form?
I can get one Multi List Box, just not several, to report using this
code i found -
Private Sub cmdPreview_Click()
|
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: 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: 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...
|
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |