javascript 过滤或截取字符串

来源:互联网 发布:分析照片的软件 编辑:程序博客网 时间:2024/05/22 17:06
 在项目开发中难免遇到通过javascript
莱按照某个字符在过滤或截取字符串
例如需要截取的字符串是 test-hello-world 就可以使用下面的方法
 
 <script language="javascript" type="text/javascript">
        
function OnCallback(strUserInfo,context)
        {
           
// result.innerText=strUserInfo;
            document.getElementById('TextBox1').value=strUserInfo;
            
var stt=strUserInfo;
            document.getElementById(
'TextBox2').value=stt.split("-")[0];
            document.getElementById(
'TextBox3').value=stt.split("-")[1];
            document.getElementById(
'TextBox4').value=stt.split("-")[2];
            
//document.write(stt.split("-")[0]);
           // document.write(stt.split("-")[1]);
            //document.write(stt.split("-")[2]);
            
            
        }
    
</script>
   明天写一下昨晚研究的关于javascript回调服务器端方法的示例