String.Split(string) ??
In .NET 1.1, String.Split(..) only accepts char datatype as a delimiter/separator. What if I want to split based on a string ? like “ as “ (read as as with a single space before and after). I couldn't find any quick solution so I came up with the following 'quick' solution :-
1) replace the separator string with a weird non-english-alphabet character like '±' (this looks like a chinese word :-) )
2) split the string using String.Split using the character chosen to represent the separator string, in this case, '±'
e.g. :-
string sql = “Max(Id) AS LastId”;
sql = sql.Replace(” AS “, “±“);
string[] values = sql.Split('±');
This seems to work for me, but I wonder is there anything that I am missing here? Apart from the fact that we are creating a temporary string (space issue) and assuming the weird '±' character will not exists in the string, is there anything else that needs to be factored in to get Split(string) to work correctly ?
Is there already a way of doing Split(string) ?