473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Split function

Reb
Hi,

I could split only by a character. How do i split by a
string.
How can i do something like this.
e.g., somestring.Split("name");

Thanks
Reb
Nov 15 '05 #1
3 10498
Hi

use Split overloaded method.

public string[] Split(
params char[] separator
);

Parameter is An array of Unicode characters that delimit
the substrings in this instance, an empty array
containing no delimiters, or a null reference (Nothing in
Visual Basic).

HTH

Ravikanth[MVP]
-----Original Message-----
Hi,

I could split only by a character. How do i split by a
string.
How can i do something like this.
e.g., somestring.Split("name");

Thanks
Reb
.

Nov 15 '05 #2
The split function just examines individual characters to determine whether
they're delimiters.

If you want to "split" by an entire string, like splitting "xyzzy name
foobar" into "xyzzy" and "foobar," you'll need to use regular expressions
(in the System.Text.RegularExpressions namespace.) The overloaded Split
function will check for individual character delimiters (e.g., "f", "o" "b"
"a" or "r") but not entire strings. Alternatively, you could roll your own
function.

"Reb" <gb***@yahoo.com> wrote in message
news:12****************************@phx.gbl...
Hi,

I could split only by a character. How do i split by a
string.
How can i do something like this.
e.g., somestring.Split("name");

Thanks
Reb

Nov 15 '05 #3
Reb,
In addition to RegEx.Split as Robert suggests, you could use
Microsoft.VisualBasic.Strings.Split which splits based on a string.

Alternatively you could create your own Split function using String.IndexOf
& String.SubString. Or use String.Replace to replace each delimiter string
with a distinct char ('\0' per haps), then use String.Split on this char.

Hope this helps
Jay

"Reb" <gb***@yahoo.com> wrote in message
news:12****************************@phx.gbl...
Hi,

I could split only by a character. How do i split by a
string.
How can i do something like this.
e.g., somestring.Split("name");

Thanks
Reb

Nov 15 '05 #4

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

Similar topics

5
by: Arjen | last post by:
Hi All, What I want to is using a string as PATTERN in a split function. This makes it possible for me to change the PATTERN on one place in my script... For example: $separator = ";"; $line...
2
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
4
by: Henry Chen | last post by:
Hi, I have a string that needs to be parsed into the string. The separator is not char. It is something like " at ". With current string.Split function, it doesn't work. Is there any exist...
5
by: Vamsi | last post by:
Hi, I am trying a basic opearation of splitting a multiline value to an array of single lines(Actually making Address into AddressLine1, AddressLine2). I used Environment.NewLine in split, I...
10
by: mb | last post by:
I was wondering if there is an easy, more useful Split function that will split with a string delimiter like "<>" or "////"?
4
by: Itzik | last post by:
can i split this string string str = "aa a - bb-b - ccc" with this delimiter string del = " - " i want recieve 3 items : "aa a" , "bb-b" , "ccc"
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
5
by: sck10 | last post by:
Hello, I have a list of email addresses that I need to send email to from the website. I am trying to use the "Split" function to get all the To's and then use the uBound function for the...
7
by: Jordi Rico | last post by:
Hi, I know I can split a string into an array doing this: Dim s As String()=Regex.Split("One-Two-Three","-") So I would have: s(0)="One" s(1)="Two"
1
by: John | last post by:
Hi I have written a Split function which in turn calls the standard string split function. Code is below; Function Split1(ByVal Expression As String, Optional ByVal Delimiter As String = " ",...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
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
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...
0
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...

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.