String split 
Author Message
 String split

I want to split a string with the separator of '//'. I can't seem to do
this.
This is my code:

string url = buttonNode.Attributes.GetNamedItem("URL", "").Value;
char slash = '//';
string[] urlSplit1 = url.Split(slash);

And I get this error for my "char slash ..." line.
 "Too many characters in character literal".

I have no problem splitting with a ';' or even '\n' - but not with the '//'.
Does anyone know how I can achieve this?

Thank you,

Lynne.



Thu, 07 Oct 2004 00:54:07 GMT  
 String split
lynne,
   Using '/' will split also //,/// etc. .
String.Split accepts only chars-not strings.It does not allow you to use only a predefined number of
repetitions of the char (2 in that case). You may want to use Regex.Split for more control.

--
Yizhaq Shmaayahoo

Quote:

> I want to split a string with the separator of '//'. I can't seem to do
> this.
> This is my code:

> string url = buttonNode.Attributes.GetNamedItem("URL", "").Value;
> char slash = '//';
> string[] urlSplit1 = url.Split(slash);

> And I get this error for my "char slash ..." line.
>  "Too many characters in character literal".

> I have no problem splitting with a ';' or even '\n' - but not with the '//'.
> Does anyone know how I can achieve this?

> Thank you,

> Lynne.



Thu, 07 Oct 2004 02:03:20 GMT  
 String split
You can use the Replace and Split together to solve your problem. But this
will cause problem if there exist single '/ ' in your original string :(


Quote:
> I want to split a string with the separator of '//'. I can't seem to do
> this.
> This is my code:

> string url = buttonNode.Attributes.GetNamedItem("URL", "").Value;
> char slash = '//';
> string[] urlSplit1 = url.Split(slash);

> And I get this error for my "char slash ..." line.
>  "Too many characters in character literal".

> I have no problem splitting with a ';' or even '\n' - but not with the
'//'.
> Does anyone know how I can achieve this?

> Thank you,

> Lynne.



Fri, 08 Oct 2004 17:38:32 GMT  
 String split
Thanks for your help guys. I will try those suggestions (although I do have
an unknown number of '/' in the string also...)

Lynne.


Quote:
> You can use the Replace and Split together to solve your problem. But this
> will cause problem if there exist single '/ ' in your original string :(



> > I want to split a string with the separator of '//'. I can't seem to do
> > this.
> > This is my code:

> > string url = buttonNode.Attributes.GetNamedItem("URL", "").Value;
> > char slash = '//';
> > string[] urlSplit1 = url.Split(slash);

> > And I get this error for my "char slash ..." line.
> >  "Too many characters in character literal".

> > I have no problem splitting with a ';' or even '\n' - but not with the
> '//'.
> > Does anyone know how I can achieve this?

> > Thank you,

> > Lynne.



Sat, 09 Oct 2004 18:13:42 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. String.Split

2. String.Split

3. help trying to figure out String.Split

4. string.split Question

5. String Split

6. tricky string-splitting problem!

7. tricky string-splitting question!

8. string.split function

9. String.Split()

10. Little question about string splitting (i know.. don't say it ;P )

11. Hard String split problem! Delimiter to demanding!

12. split a string syntax

 

 
Powered by phpBB® Forum Software