Q: Tricky Split Question

  • Thread starter Thread starter Martin Arvidsson, Visual Systems AB
  • Start date Start date
M

Martin Arvidsson, Visual Systems AB

Hi!

I have a string containing this information:

Including file: Myfile.fle (C:\Program
Files\Application\Source\Myfile.fle)
After myfile.fle there are three spaces!

Since i use the folowing:

string[] splitted = unsplittedString.split(new char[]{' '})

The splitted string is outputed like this ofcourse:
Including
file:
Myfile.fle


(C:\Program
Files\Application\Source\Myfile.fle)

which is correct. BUT, now for the tricky part.

I only want to split if there is only ONE space and i dont want to split
anything between the ( and )

so basicly i want this output:
Including
file:
Myfile.fle
(C:\Program Files\Application\Source\Myfile.fle)

Any ideas you geniouses out there :)

/Martin
 
Hi!

I have a string containing this information:

Including file: Myfile.fle (C:\Program
Files\Application\Source\Myfile.fle)
After myfile.fle there are three spaces!

Since i use the folowing:

string[] splitted = unsplittedString.split(new char[]{' '})

The splitted string is outputed like this ofcourse:
Including
file:
Myfile.fle

(C:\Program
Files\Application\Source\Myfile.fle)

which is correct. BUT, now for the tricky part.

I only want to split if there is only ONE space and i dont want to split
anything between the ( and )

so basicly i want this output:
Including
file:
Myfile.fle
(C:\Program Files\Application\Source\Myfile.fle)

Any ideas you geniouses out there :)

/Martin

If I understand you correctly changing the line to

string[] splitted = unsplittedString.split(new char[]{' '},
StringSplitOptions.RemoveEmptyEntries)
I am assuming that the two spaces before (C:\Program files...) aren't
necessary.

Hope this helps.
 
Hi,

I do not quite understand what you want.

What are you trying to do by spliting it in spaces?
 
Back
Top