String to string Array

B

Bruce Wiebe

Hi all

I have a string that contains a list of email addresses in the format
{"(e-mail address removed)","(e-mail address removed)"} and i need to convert it to a string array in the
same format so my array would loook like

dim emailaddresses() as string={"(e-mail address removed)","(e-mail address removed)"}

Does anyone know an easy way to do this

Thanks in advance
 
J

Jan Tielens

You could use the Split method of the String class:
dim emailaddresses() as string = xxx.Split(",")

If your xxx string looks like {"(e-mail address removed)","(e-mail address removed)"}, so it contains { and "
characters, you need to strip them off.


--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 
T

Trev Hunter

Try the "String.Split" method.

e.g.

-------------------------

Dim szSource as String = "(e-mail address removed),[email protected]"
Dim aEmails as String() = szSource.Split(","c)

-------------------------

The above example uses a comma (,) as the delimiter between the email
addresses.

HTH,

Trev.
 
A

Armin Zingler

Bruce Wiebe said:
I have a string that contains a list of email addresses in the format
{"(e-mail address removed)","(e-mail address removed)"} and i need to convert it to a string array in
the
same format so my array would loook like

dim emailaddresses() as string={"(e-mail address removed)","(e-mail address removed)"}

Does anyone know an easy way to do this

dim s as string()

s = yourstring.split(","c)
 
J

Jay B. Harlow [MVP - Outlook]

Bruce,
As the other have pointed out have you looked at one of the 3 split methods?

Its unclear from your post, does the input string literally contain quotes &
curly braces? You may need to do a little more work. In addition to
RegEx.Split you can use one of the email patterns & RegEx.Matches to find
all the email addresses in a string, which for your string may be the easier
method. A variation of the following topics:

http://msdn.microsoft.com/library/d...html/cpconexampleextractingurlinformation.asp

http://msdn.microsoft.com/library/d...html/cpconexampleextractingurlinformation.asp


There are three Split functions in .NET:

Use Microsoft.VisualBasic.Strings.Split if you need to split a string based
on a specific word (string). It is the Split function from VB6.

Use System.String.Split if you need to split a string based on a collection
of specific characters. Each individual character is its own delimiter.

Use System.Text.RegularExpressions.RegEx.Split to split based
on matching patterns.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top