473,503 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Delimiter Split

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
a string with a delimiter of more than one character.
What is the correct syntax?

string str = "First<;>Second<;>Third";

// This does not work, it gives an "Unhandled Exception
// of type 'System.ExecutionEngineException' in
// mscorlib.dll"
string[] strArray = str.Split(new char[] {'<',';','>'});

Thanks!
Nov 17 '05 #1
2 1420
Hi,

the relationship between chars is OR and not AND.
http://msdn.microsoft.com/library/de.../en-us/cpref/h
tml/frlrfsystemstringclasssplittopic1.asp

Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2
"Mark Fox" <in**@solelsoftware.com> wrote in
news:02****************************@phx.gbl:
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
a string with a delimiter of more than one character.
What is the correct syntax?

string str = "First<;>Second<;>Third";

// This does not work, it gives an "Unhandled Exception
// of type 'System.ExecutionEngineException' in
// mscorlib.dll"
string[] strArray = str.Split(new char[] {'<',';','>'});


Mark,

To split on multiple characters, use the Regex.Split method:

using System.Text.RegularExpressions;

...

string str = "First<;>Second<;>Third";
string[] strArray = Regex.Split(str, "<;>");
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14363
by: Laurent | last post by:
Hello, is it possible to read a file in python line by line by redefining a new end-of-line delimiter ? I would like for example to have the string "END" being the new delimiter for each...
2
4321
by: rhungund | last post by:
Hey all... I'm submitting various form variables as arrays, so when I do try to access them when the form is submitted, i do a split on the variable and pop it into an array. for example:...
3
19300
by: Hetal Shah | last post by:
It is a C# code. I have a string like, one||two||three I want to split it into one, two and three. string str = "one||two||three"; string myStrs = str.Split("||");
2
2002
by: Elhanan | last post by:
hi all.. i have the following string: 200850625~01~464~^^200850625~01~464~^^200850625~01~908~^^ which i will need to turn to a mutli-dimentional string array i used result.Split(new...
16
8223
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. ...
4
1132
by: gn | last post by:
I am trying to parse a txt file which looks something like example below: thisemail@email.com thatemail@email.com anotheremail@email.com This is the code I am using: filetoread =...
2
2678
by: pengb | last post by:
Hello All: A pretty frustrating question to ask! I use the string something = stringx.split (delimiter.tochararray()) mathod to delimit a long string by space! So supposely if the stringx is :...
3
1334
chandru8
by: chandru8 | last post by:
Hi to all My user will upload a excel file in to an access 2003 database, the problem is date format for that i used the split function to split the date from the excel. The problem is in the...
3
2099
by: gh | last post by:
I have a string that is delimited with commas. Is there a function in C# that will break apart the string at each comma, so I can copy the value to a var? This is a .net v1.1.4 app. TIA
0
7198
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,...
0
7072
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...
0
7319
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...
1
6979
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...
0
7449
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...
1
4998
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...
0
4666
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...
0
3160
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...
1
730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.