时间: 2021-07-31 作者:daque
//// strreplace.java//package forum;import java.util.*;/*** title:* description:* copyright: copyright (c) 2001* company:* @author* @version 1.0*/public class strreplace {public strreplace() {}public string str_replace(string from,string to,string source){stringbuffer bf= new stringbuffer("");stringtokenizer st = new stringtokenizer(source,from,true);while (st.hasmoretokens()){string tmp = st.nexttoken();system.out.println("*"+tmp);if(tmp.equals(from)){bf.append(to);}else{bf.append(tmp);}}return bf.tostring();}}// 运用本领<jsp:usebean id="replace" scope="page" class="forum.strreplace" /><%= replace.str_replace("<","^","<h1>123456</h1>") %>