JS 從一個字串中截取兩個字串之間的字串

來源:互聯網
上載者:User

標籤:

/*************************************************函數說明:從一個字串中截取 兩個字串之間的字串參數說明:src_str 原串, start_str_loc開始尋找的字串, start_str起始字串   end_str結束字串dep     :兩個字串之間的字串/************************************************/function analysysRespParam(src_str,start_str_loc,start_str,end_str) {    src_str = "" + src_str;    start_str_loc = "" + start_str_loc;    start_str = "" + start_str;    end_str = "" + end_str;    var depe;    try    {        var start_loc = src_str.indexOf(start_str_loc);                                            //start_str_loc的起始位置        if(start_loc == -1 )                                                                                                //沒有找到 返回空        {            return "";        }                var deps_loc = start_loc + start_str_loc.length ;                                        //start_str_loc的結束位置  即開始尋找的位置        var start_str_real_loc = src_str.indexOf(start_str,deps_loc);                //start_str的起始位置        if(start_str_real_loc == -1)        {            return "";        }        var deps = start_str_real_loc + start_str.length;                                        //開始截取的未知        if(end_str.equals(""))                                                                                            //如果end_str為空白 則截取到最後        {                        depe = (src_str.length);        }        else        {            depe = src_str.indexOf(end_str,deps_loc);            if(depe == -1)            {                return "";            }        }        var dep = src_str.substr(deps,depe-deps);                                                        //截取字串        return dep;    }    catch(e)    {        log("Error:" + CHANNELINFO + "156-analysysRespParam函數中解析返回異常.e=" + e);        var dep = "";        return dep;    }}
截取兩個字串中間的字串

 

JS 從一個字串中截取兩個字串之間的字串

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.