行テキストがあります。このテキストからイベントとインテント アクティビティを作成し、それらをリストに追加してからデータベースにインポートします。もっと具体的に言ってみましょう。次の文があると仮定しましょう。Party2ではヒップホップの曲に合わせてカラオケやダンスをします。」</p>
私の欲望の出力は次のようになりたいです:
イベント 1: パーティー 1
Activitie1: take some drinks
Activitie2: eat very good food
Activitie3: play ps3 games
イベント 2: パーティー 2
Activitie1: do karaoke
Activitie2: dance with hip hop songs
私が今までやってきたことは、特殊文字「#、*」を許可することです。したがって、* の場合はイベントを生成し、# の場合はアクティビティを生成します。その結果、イベントや活動をプロデュースすることはできますが、それらに匹敵することはできません。生成された要素を一致させる (意図する) 方法を見つける必要があります。私のコード:
string astring = Convert.ToString(lblrowtext.Text);
if (astring.IndexOf("#") >= 0 || astring.IndexOf("*") >= 0)
{
string[] Eventsarray;
string[] Activitiessarray;
List<string> listofEvents = new List<string>();
List<string> listofActivities = new List<string>();
Activitiessarray = Regex.Matches(astring, @"#([^\*#]*)").Cast<Match>()
.Select(m => m.Groups[1].Value).ToArray();
Eventsarray = Regex.Matches(astring, @"\*([^\*#]*)").Cast<Match>()
.Select(m => m.Groups[1].Value).ToArray();
if (Activitiessarray != null)
{
if (Activitiessarray.Count() > 0)
{
listofActivities = new List<string>(Activitiessarray);
ViewState["listofActivities"] = listofActivities;
Repeater1.DataSource = listofActivities;
Repeater1.DataBind();
}
if (Eventsarray != null)
{
if (Eventsarray.Count() > 0)
{
listofEvents = new List<string>(Eventsarray);
ViewState["listofEvents"] = listofEvents;
Repeater2.DataSource = listofEvents;
Repeater2.DataBind();
}
}
}
}