用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心Java

About UBB with java has a bug.

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 17:25:15
// 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();
        }  
    }
}    

Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
PB创新网ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:12,296.88000 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号