每次用到JS替换字符串都要想半天,给他写出来得了。。

<script language="javascript">
$(function(){
 var str = 'rtsp://123.1.123.12:1234567/1d8a097f_51bf_4ef2_8380_71d63e9fb97a/c1v1.3gp';
    var re = /\:\/\/.*$/i;
    if(re.test(str)){
   var newStr = str.substring(str.indexOf("://")+3, str.length);
   var strarray = newStr.split("/");
   alert(strarray[0].substring(0, strarray[0].indexOf(":")));
  
   alert(replaceStr(strarray[1]));
 }
 function replaceStr(str){
    var newstring = str;
    while(newstring.indexOf("_") > 0) 
    {
    newstring = newstring.replace("_","-");
     }
 return newstring;
   }
});
</script>

相关文章:

  • 2021-12-13
  • 2022-01-05
  • 2022-12-23
  • 2021-05-10
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
  • 2021-12-02
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案