從標籤中提取參數(數組)

protected void rp()
    {
        string t="aaaaaaaaaaaaaa{$link(20085,35502)$}bbbbbbbbbbbb";
        Response.Write("測試來了<br>");
        Response.Write("原始標籤"+ t + "<br>");
        int a1=t.IndexOf("{$link(");
        Response.Write("標籤開始位置:"+a1 +"<br>");
        int a = t.Length;
        Response.Write("字符串總長度:"+a +"<br>");

        string t1 = t.Substring(a1, a-a1);
        Response.Write("去掉前面後的字符串:" + t1 + "<br>");

        int a2 = t1.IndexOf(")$}");
        Response.Write("標籤結束位置:" + a2 + "<br>");

        string tt = t.Substring(a1, a2).Replace("{$link(", "");
        Response.Write("截取出來的參數:" + tt + "<br>");

        string[] strarray = tt.Split(',');
        int arrL = strarray.Length;
        Response.Write("參數數組長度:"+arrL +"<BR>");
        Response.Write("列出數組元素:<br>");
        for (int j = 0; j < arrL; j++)
        {
            Response.Write("第"+j+"個數組元素:"+strarray[j] +"<br>");
        }
    } 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章