C# Split string into readable sentences

92 views Asked by At

This string is an error that comes from an AVAYA phone system. I've been trying to parse this darn string into readable sentences, but I haven't had much luck. Here's the offending string: "cadd hunt-group 109\ne3 0005ff00 d6d8 "34257 " Extension previously assigned; please select another\ne2 0005ff00 c6d5 Group extension must be specified\nt\n"

I've tried Regex "string[] splitCommand = Regex.Split(commandResult, @"\W+");" but that splits into individual words, and the count of words varies depending on the type of error, so I don't think that will work. I've tried splitting on "", "\ne" and a few other things, but I just can't seem to get it.. any ideas?

Thanks!

Dave

1

There are 1 answers

1
LunicLynx On

The correct format should probably be:

cadd hunt-group 109
e3 0005ff00 d6d8 "34257 " Extension previously assigned; please select another
e2 0005ff00 c6d5 Group extension must be specified
t

To get this result use:

string s = "<input>";
s.Split("\\n");