Hey everybody !
i've got some troubles to split a text, i need to split it according to chars, like "|" ," :" , or" \n", but i also need to split it according to Regex, and the method split(char[]) doesn't allow regex, when i try this :
string[] separators = { "|", "!", ":", "\n", @"=...+" }; string[] SplittedText = alltext.Split(separators,StringSplitOptions.RemoveEmptyEntries);
the last one doesn't work and my result array "splittedtext" still contains the lines with "========= ....." is there a solution except the fact to first split my text according to @"=...+" and then split it again according to "|", "!", ":", "\n" ???
THX !
VulpesPosted Dec 18, 2014, 10:31 AM
jean tindelPosted Dec 18, 2014, 10:17 AM
VulpesPosted Dec 18, 2014, 10:09 AM
jean tindelPosted Dec 18, 2014, 9:34 AM
yeah your solution works fine but my input file is not in "raw" if you know what i mean, i am using "string alltext = File.ReadAllText( string PathOfFile)"
and in this case, where should i write the "@" ?
Ramchand RepallePosted Dec 18, 2014, 9:09 AM
I have tried with the separators you mentioned above. It seems working fine..
Please check with dotnet fiddle code once: https://dotnetfiddle.net/Y6Js0D
Thanks,
Ramchand