·您的位置: 首页 » 资源教程 » 编程开发 » JAVA、JSP » About UBB with java has a bug.

About UBB with java has a bug.

类别: JAVA教程  评论数:0 总得分:0
// the bug has been fixed
/*+-------------------------------
    $REReplace.java 2001-9-4
    $author pizer.chen
    $history:
        0.2 fixed a bug.
        0.1 ...
+-------------------------------*/
package com.wacos.util.ubb;

import java.io.*;
import java.util.*;
import org.apache.regexp.*;
/**
*
* @author  Pizer.chen -- iceant -- 陈鹏
* @version 0.2
*/
public class REReplace
{
    /**
     * replace the inStr with pattern1 & pattern2
    **/
    public static String replace(String pattern1,String pattern2,String inStr){
        try {
            RE re = new RE(pattern1);
            RE re2 = new RE("//$([0-9])");
            String tempPat2=pattern2;
            int point=0;
            while(re.match(inStr)){
                while(re2.match(pattern2)){
                    point = Integer.parseInt(re2.getParen(1));
                    pattern2=re2.subst(pattern2,re.getParen(point),RE.REPLACE_FIRSTONLY);
                }
                inStr = re.subst(inStr,pattern2,RE.REPLACE_FIRSTONLY);
                pattern2 = tempPat2;
            }
            return inStr;
        }
        catch (Exception e) {
            System.out.println(e);
            return e.toString();
        }  
    }
}    


-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1