我有一个字符串比如"cnnehttp://wwww.我很好.com" 或"www.ccn.我好了.cn",我想获得的结果是从http://或www开始截取,将前面的"cnne"去掉,后面只要发现汉字,比如"我很好“就截取掉,java程序中,高手指教
參考答案:<html>
<head>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<script language="javascript">
function cut(){
len=form1.text.value.length;
for(x=0;x<len;x++)
{
if(form1.text.value.charCodeAt(x)<0||form1.text.value.charCodeAt(x)>255)
{
tt=form1.text.value.substring(x,x+1);
form1.text.value=form1.text.value.replace(tt,"");
x--;
}
}
sub=form1.text.value.indexOf("")
str=form1.text.value.substr(sub)
alert(str);
}
</script>
</head>
<body>
<form name="form1" id="form1" method="post">
<input id="text" name="text" type="text"> <input id="button1" name="button1" type="button" onclick="return cut()" value="button">
</form>
</body>
</html>