欢迎光临
我们一直在努力

About UBB with java has a bug.-JSP教程,Java技巧及代码

建站超值云服务器,限时71元/月

// 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();
        }  
    }
}    

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » About UBB with java has a bug.-JSP教程,Java技巧及代码
分享到: 更多 (0)