0227.htm

来自「JspServlet教程专栏 对javaservlet讲述的非常详细」· HTM 代码 · 共 48 行

HTM
48
字号
<html>

<head>
<title>新时代软件教程:操作系统 主页制作 服务器 设计软件 网络技术 编程语言 文字编辑</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
<!--
body, table {font-size: 9pt; font-family: 宋体}
a {text-decoration:none}
a:hover {color: red;text-decoration:underline}
.1  {background-color: rgb(245,245,245)}
-->
</style>
</head>
<p align="center"><script src="../../1.js"></script></a>
<p align="center"><big><strong>有用的字符串替换函数</strong></big></p>
<div align="right">---&nbsp;(文/何志强)</div>

<br>/*<br>
作者:何志强[hhzqq@21cn.com]<br>
日期:2000-07-25<br>
功能:字符串替换<br>
*/<br>
<br>
package&nbsp; pipi.string;<br>
<br>
public&nbsp; final&nbsp; class&nbsp; Replace{<br>
public&nbsp; static&nbsp; java.lang.String&nbsp; replace(java.lang.String&nbsp; strSource,java.lang.String&nbsp; strFrom,java.lang.String&nbsp; strTo){<br>
java.lang.String&nbsp; strDest&nbsp; =&nbsp; "";<br>
int&nbsp; intFromLen&nbsp; =&nbsp; strFrom.length();<br>
int&nbsp; intPos;<br>
<br>
while((intPos=strSource.indexOf(strFrom))!=-1){<br>
strDest&nbsp; =&nbsp; strDest&nbsp; +&nbsp; strSource.substring(0,intPos);<br>
strDest&nbsp; =&nbsp; strDest&nbsp; +&nbsp; strTo;<br>
strSource&nbsp; =&nbsp; strSource.substring(intPos+intFromLen);<br>
}<br>
strDest&nbsp; =&nbsp; strDest&nbsp; +&nbsp; strSource;<br>
<br>
return&nbsp; strDest;<br>
}<br>
}

  </table>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?