首页 > 编程知识 正文

js截取最后一个逗号,js截取指定字符后面的内容

时间:2023-05-06 10:11:19 阅读:35573 作者:3037

获取//URL的最后一个字符串

geturl sub :功能(href ) {

letindex=href.lastindexof (()/);

letstr=href.substring(index1,href.length );

返回str

(,

//URL获取第3.4.5个字符串

getn exturl :功能(href ) {

if(href===undefined ) {

return 'formFields '

}else{

leturls=(href.split(/)/(3) ) )/(href.split (/) )4) )/(href.split (/) ) )5) ) )

控制台. log (URLs ) )。

返回URLs;

}

(,

获取//URL倒数第二个字段

getsecondurl:function{

//获取最后一个正斜杠之前的内容

//varhtmlhref=window.location.href;

letindex=href.lastindexof (()/);

letstr=href.substring(0,index 1);

letURL=str.substring(0,str.length-1 ) )。

返回链接

}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。