function getCaption(obj,state) {
var index=obj.lastIndexOf("\-");
if(state==0){
obj=obj.substring(0,index);
}else {
obj=obj.substring(index+1,obj.length);
}
return obj;
}
var data = 'aaa-bbb'
//截取符号前面部分
getCaption(data,0) //输出aaa
//截取符号后面部分
getCaption(data,1) //输出bbb

原文链接:https://blog.csdn.net/caiyongshengCSDN/article/details/88420416

相关文章:

  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案