C#でsscanfしたいなという人が絶対にいると思っていたら
ネットにあったのでその紹介。
これは同時に以下のTextParserというものを利用している。
(Microsoft.VisualBasic.FileIOにもTextParserクラスがあるが、それとは別)
www.blackbeltcoder.com
private void button1_Click(object sender, EventArgs e) { ScanFormatted scan = new ScanFormatted(); scan.Parse("hoge1foo2bar3", "hoge%dfoo%dbar%d"); foreach (var item in scan.Results) { Debug.WriteLine("{0}", item); } //1 //2 //3 }
のようだ。