c# regexを使用して、すべての「rect NAME = null」を見つけるのに役立ちます。(グローバルとエンドグローバルの間)
//Text example:
...
globals
...
boolexpr cj_true_bool_4896bnao87
string udg_globals = "endglobals"
trigger gg_trg___________________________u=null
rect gg_rct_MyReg1=null
rect ra2462346 = null
...
endglobals
...
私のコード(、作業中):
private void openFileDialog1_FileOk(object sender, CancelEventArgs e) { string startglobs = @"^\s*globals\s*$"; string endglobs = @"^\s*endglobals\s*$"; string currrect = @"^\s*rect\s+(. )\s =\s*null\s*";
using (StreamReader file = new StreamReader(openFileDialog1.FileName)) { string currline; bool globalstate = false; while ((currline = file.ReadLine()) != null) { /* find globals */ Regex startr = new Regex(startglobs); Match startm = startr.Match(currline); if (startm.Success) globalstate = true; /* find endglobls */ Regex endr = new Regex(endglobs); Match endm = endr.Match(currline); if (endm.Success) globalstate = false; /* if opened globals find global rect */ if (globalstate) { Regex foundrectr = new Regex(currrect); Match foundrectm = foundrectr.Match(currline); if (foundrectm.Success) { MessageBox.Show(foundrectm.Groups[1].ToString()); } } } } }