Question split question

andrews

Well-known member
Joined
Nov 22, 2011
Messages
167
Programming Experience
5-10
I have a textfile with many lines and want to place all the words separately in an array() as string
but there are different separators like " " or " " or " " , but always spaces
is there a solution to split each line automatically in one time?
Thanks for any resonse
 
Spaces are truncated in web view, but you're asking about splitting for one or more spaces.

You could use the String.Split method with single space and use the StringSplitOptions.RemoveEmptyEntries.

There is also Regex.Split method where you can use the " +" or " {1,}" patterns that both means 'space one or more times'. The latter type of expression is more useful if you want to split two or more with " {2,}" and keep single spaces in text.
 
Back
Top