I need help developing logic for line splitting, but only based on the last two line breaks.
Input Example:
string s1 = "Dog \ Cat \ Bird \ Cow";
string s2 = "Hello \ World \ How \ Are \ You";
string s3 = "I \ am \ Peter";
Expected results:
string[] newS1 = "Dog Cat", "Bird", "Cow"
string[] newS2 = "Hello World How", "Are", "You"
string[] newS3 = "I", "am", "Peter"
So, as you can see, I want to split the line into the last 2 "\", and everything else until the last 2 "\" will be combined into one line.
I tried the .Split method, but it just split each "\" in the string.
Edited: if the line has less than 2 "\", it will simply be split into everything that it has
Updates: Wow, this is a bunch of interesting solutions! Thank you very much!
source
share