WEB开发网
开发学院WEB开发Jsp About UBB with java has a bug. 阅读

About UBB with java has a bug.

 2008-01-05 08:47:54 来源:WEB开发网   
核心提示:// 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.*;impor

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

Tags:About UBB with

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接