<script>
var str="查找一个string中如含有~符号的,如果有该符号,符后前与符后号各自成为新的自符";
var arr=str.split("~");
for(var i=0;i<arr.length;i++)
alert(arr[i])+"\n";
</script>

解决方案 »

  1.   

    我也搞了一个function subnote(note)
     {
            //note是全部字符串,后两个变量一个代表~前部,一个是~后部
             var subnote 
    var baggage
    var i
    if(note.indexOf("~")>=0)
    {
    i=note.indexOf("~");
             subnote=note.substr(0,i);
    baggage=note.substr(i+1,note.length);
    window.alert("subnote:"+subnote+",baggage:"+baggage);
    }
        else
        {
             subnote=note;
    baggage="";
    window.alert("subnote:"+subnote+",baggage:"+baggage);
         }
     }