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