でこれはサンプルテキストファイルカウントパターン/文字列の出現ASP.Net
ラインがライン日付ごと、日付ごとに分類されるが、例えば、12月1日及び2のように繰り返すことができることです2つのエントリがあります。 期待される出力は、パターン "D;"を数える必要があります。日付ごとに例えば
2016-12-01 - 7
2016-12-02 - 9
2016-12-03 - 5
これは、私は現在、
using (StreamReader stRead = new StreamReader(FileUpload1.PostedFile.InputStream))
{
while (!stRead.EndOfStream)
{
var readedLine = stRead.ReadLine();
if (!string.IsNullOrWhiteSpace(readedLine))
{
for (int j = 01; j <= 31; j++)
{
int readedLineTime = Convert.ToInt32(readedLine.Substring(09, 02));
if (readedLineTime == j)
{
MatchCollection collection = Regex.Matches(readedLine, @"D;");
countedChars = collection.Count;
textfileOutput += readedLine.Substring(0, 11) + " - " + countedChars + Environment.NewLine;
}
}
}
textfileContent += readedLine + Environment.NewLine;
i++;
}
TextBox1.Text = textfileOutput;
TextBox2.Text = textfileContent;
Label1.Text = i.ToString();
//Label1.Text = this.TextBox1.Text.Split(new Char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Length.ToString();
// Label2.Text = filename;
}
を持っており、これは
2016-12-01 - 4
2016-12-01 - 3
2016-12-02 - 4
2016-12-02 - 5
2016-12-03 - 5
リッキー次の印刷または何か、使用のためにこれらの値を使用するので、あなたはそれに対して「D」の出現の日付と番号をしたいです。それは正しい理解ですか? – A3006
「D;」の出現を数えたいと思います。日付ごとに各行に入力し、例と同じように、同じ日付で数を数えたり組み合わせたりしてください。 – rickyProgrammer
よろしいですか。そして、(int j = 01; j <= 31; j ++)のためのものは何ですか?また、あなたの入力ファイルは "csv"ですか? – A3006