regex - C# - Problem removing items in List1 & List2 from List3 -
regex - C# - Problem removing items in List1 & List2 from List3 -
i have file reading in, splitting different lists , outputting them richtextbox read 3 different listboxes. doing of this, have come across not know how fix/work around.
my code below , seem having problem understanding why fails work when gets match tworegex = regex.match(...) section of code.
code:
private void sortdatalines() { seek { // reads lines in file format. var filereader = file.opentext(opengcfile.filename); // creates list lines stored in. var placementuserdefinedlist = new list<string>(); // reads first line , nil it. filereader.readline(); // adds each line in file list. while (true) { var line = filereader.readline(); if (line == null) break; placementuserdefinedlist.add(line); } // creates new lists hold matches each list. var oneresult = new list<string>(); var tworesult = new list<string>(); var mainresult = new list<string>(); foreach (var userline in placementuserdefinedlist) mainresult.add(string.join(" ", userline)); foreach (var oneline in mainresult) { // placement 1 regex match oneregex = regex.match(oneline, @"^.+(res|0402|0201|0603|0805|1206|1306|1608|3216|2551" + @"|1913|1313|2513|5125|2525|5619|3813|1508|6431|2512|1505|2208|1005|1010|2010|0505|0705" + @"|1020|1812|2225|5764|4532|1210|0816|0363|sot)"); if (oneregex.success) oneresult.add(string.join(" ", oneline)); } // // section fails.. // foreach(var twoline in mainresult) { //placement 2 regex match tworegex = regex.match(twoline, @"^.+(bga|sop8|qsop|tqsop|soic16|soic12|soic8|so8|so08" + @"cqfp|lcc|lga|osccc|plcc|qfn|qfp|soj|son"); if (tworegex.success) tworesult.add(string.join(" ", twoline)); } // removes matched values both of regex used above. list<string> userresult = mainresult.except(oneresult).tolist(); userresult = userresult.except(tworesult).tolist(); // prints proper values assigned richtextboxes. foreach (var line in userresult) userdefinedrichtextbox.appendtext(line + "\n"); foreach (var line in oneresult) placementonerichtextbox.appendtext(line + "\n"); foreach (var line in tworesult) placementtworichtextbox.appendtext(line + "\n"); } // catches exception if file not opened. grab (exception) { messagebox.show("could not match regex values.", "regular look match error", messageboxbuttons.ok, messageboxicon.warning); } } questions:
does understand why unable to find, or fail at, sec set of regex? with that, there way prepare it? suggestions please! :)
haven't missed pipeline character in sec regex between 2 lines?
c# regex list text-files
Comments
Post a Comment