呵呵, 真有趣, 居然發現自己古時候寫的文章:
https://maxtellyou.blogspot.com/2012/08/javascript-left-right-leftfield.html
function leftField(str,delimit)
{
var returnValue=str;
var indexNumber=str.indexOf(delimit);
if(indexNumber>=0){
returnValue = str.substring(0,str.indexOf(delimit))
}
return returnValue;
}
function rightField(str,delimit)
{
var returnValue=str;
var indexNumber=str.indexOf(delimit);
if(indexNumber>=0){
returnValue = str.substring(indexNumber+delimit.length,str.length)
}
return returnValue;
}