C# .Net - How do I split a string that varies in the words and characters within it? -


i need split strings, number of characters , position change, quite easy in php seems more complicated in c#.

these greyhound results in uk.

i have these strings in array, i need extract each string, need quick , simple solution this. need able extract date, time, course(crayfd), distance(540m), winner only(no "winner(s): ", need remove this), , marketid url.

so built in c# functions best suited this?, small example of c# functions , how use them great. small explanation great.

[0, 0] = "bags cards / crayfd 2nd jul - 12:58 s6 540m settled" [0, 1] = "winner(s):  springtown mary" [0, 2] = "http://rss.betfair.com/index.aspx?format=html&sportid=4339&marketid=103165302"  [1, 0] = "bags cards / crayfd 2nd jul - 12:58 placed settled" [1, 1] = "winner(s):  black hawk boy,  springtown mary" [1, 2] = "http://rss.betfair.com/index.aspx?format=html&sportid=4339&marketid=103165303"  [2, 0] = "forecast betting / crayfd (fc) 2nd july - 12:58 forecast settled" [2, 1] = "winner(s): 1 - 3" [2, 2] = "http://rss.betfair.com/index.aspx?format=html&sportid=4339&marketid=103164570"  [3, 0] = "bags cards / romfd 2nd jul - 12:49 a2 400m settled" [3, 1] = "winner(s):  come on rosie" [3, 2] = "http://rss.betfair.com/index.aspx?format=html&sportid=4339&marketid=103165272" 

i'd suggest using string.split, string.[last]indexof, string.substring, , linq extensions (simple ones, e.g. .last(), simplify things). e.g. if url in string url , it's safe assume marketid @ end that:

int marketid = int.parse(url.split('=').last()); 

or things first line, if it's called courseetc:

string[] courseetcparts = courseetc.split('/', '-'); string[] lastparts = courseetcparts.split(); string time = lastparts[0]; 

and distance, use regex. [0-9]+m.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -