c# - Splitting strings with a regex -


i struggling find out how can achieve this. here content:

"#1 single" (2006) {window shopping (#1.2)} uk:29 january 2006

"the wright stuff" (2000) {(#15.76)} germany:25 april 2011

fever (2014/i) brazil:26 february 2015 (cinequest film festival)

fever (2014/ii) usa:june 2014

above variation of different strings, have of these strings in list<string> , want first part e.g. the wright stuff , last part germany 25 april 2011. if had dictionary<int,list<string>> this:

new dictionary<int, list<string>> {     {         1, new list<string>()             {                 "the wright stuff",                 "germany",                 "25 april 2011"             }         }      }; 

the above want outcome (don't worry dictionary's key, guid in actual application).

but if string has bit on end fever (2014/i) brazil:26 february 2015 (cinequest film festival) want (cinequest film festival) added too.

can assist me this?

without using regex, solved following way (as discussed in comments):

var thelistofstring = yourinputstring.split(new[] { "  ", ":" }, stringsplitoptions.removeemptyentries).select(p => p.trim()).tolist(); thelistofstring[0] = thelistofstring[0].substring(0, thelistofstring[0].indexof("(") - 1); 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -